You are here: Robert Dale's Home Page > Resources > Writing Advice for Students > Declarative Formatting

LaTeX Tips: Declarative Formatting


People sometimes get sloppy about the use of notational conventions: on page 1 they might use italics for a linguistic example, and then on page 3 they might mark it off with quotes instead; on the next page, you might find they have used both conventions at once, putting linguistic examples in italics and inside quotes at the same time. It makes sense to help your reader by being consistent about the notational conventions you adopt, whatever they might be.

One solution is to write some macros that enforce a little more discipline. The idea is that, in the best tradition of declarative formatting, you say what something is rather than how it should appear.

Suppose in the preamble of your file (i.e., between the \documentstyle and \begin{document} lines) you have the following definitions:

\newcommand{\lingform}[1]{{\it #1}}
\newcommand{\term}[1]{{\bf #1}}
\newcommand{\scare}[1]{`#1'} 
\newcommand{\code}[1]{{\tt #1}}
Then:

Note that this is just one possible set of conventions; many people use other conventions. You can define whatever notational conventions you like. The basic point is that it's good practice to always use explicit declaratively-named commands for notational conventions: this ensures consistency, makes it very easy to perform global changes, and makes you think about what you're doing. Suppose you use single quotes as scare quotes, and then submit your manuscript to a journal; it might well come back with the request that you use double quotes instead---global changes in an editor would only get you so far. Using declarative formatting techniques, you only have to change the definition and then reformat your document.

To define new conventions, just insert commands of the form below into the preamble of your file:

\newcommand{\prolog}[1]{\verb!#1!}
This particular example defines a command, \prolog, which takes one argument and sets it in verbatim mode: I use this for elements of Prolog code embedded in the text, like this: append/1. That bit of formatting was generated from the following text:
... in the text, like this: \prolog{append/1}.
Another example, just to push the point home: the following command takes one argument and sets it in italic face:
\newcommand{\latin}[1]{{\it #1}}
This means I don't have to think twice about formatting when I want to write Latin phrases like ad hoc or per se; I just type
... Latin phrases like \latin{ad hoc} or \latin{per se} ...
Exercise for the reader: work out what notational conventions you typically use and email me the list. I'm interested in that kind of thing.

If there are particular things you think this document doesn't contain that it should, or if you disagree strongly with something it contains, or if you think there's something that isn't clear or could be expressed in a better way, please let me know. This document has benefitted from input from Sophia Cormack, Ivan Derzhanski, Dawn Griesbach, Masato Ishizaki, Ewan Klein, Alex Lascarides and Sandy Nelson. It was last significantly revised on 27th March 1993, and since then has only suffered conversion into HTML.

[Home|Teaching|Research|Publications|Professional Activities|Resources]


Please send comments or queries about this web site to Robert.Dale@mq.edu.au
Last Modified: 4 May 2007