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:

• If you want to place a linguistic example in the body of the text, as in the following example:
The sentence John loves Mary is English.
then you can use the \lingform command. This takes one argument, this being the linguistic form in question. So, for example, the text above was generated from:
The sentence \lingform{John loves Mary} is English.

• If you want to use a piece of new terminology for the first time, use the \term command. For example:
The definite determiner is the.
Like \lingform, \term takes one argument. The text above was generated from
The \term{definite determiner} is \lingform{the}.


• If you want to put something in scare quotes, don't explicitly use quotes. Instead, use the \scare command, which again takes one argument, this being the thing to be scare quoted.
The 'rebels' were actually government agents.
The above text was generated from
The \scare{rebels} were actually government agents.

This stops you from using single quotes on one page and double quotes on the next, for example. Make sure scare quotes are what you want: don't use them for new terminology, for example.

• For procedure or variable names, or other short elements of programming code, typing \code{GetProofingPointer} gets you GetProofingPointer.
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.