177

When working with large documents, or even across multiple (smaller) documents, I often find that I forget which typographical consistencies I should stick to.

With TeX being inherently consistent in the way it does things, most things are kept organized without the user even knowing about it. Additionally, using a customized documentclass (like memoir, for example) or packages (like xspace and titlesec, to name two) improves on this consistency by user's choice. Sometimes, however, you are left to your own devices and have to do things manually. Of course, the latter could also stem from not knowing that a package exists to do the job for you, or because you'd rather have more control over the placement/use of a certain things without having it automated or globally set.

To this extent, I though this would be a good place to ask the question: "Which tools/techniques do you use to maintain consistency within your document?"

Sure, the question sounds broad. Many answers are scattered across this site and elsewhere (like the Chicago Manual of Style or Bringhurst's Elements of Typographic Style). I was hoping to contain this diverse knowledge base in one location on TeX.SX (similar to what was done for Showcase of beautiful typography done in TeX & friends and LaTeX IDEs).

Here are some examples of useful (manual) tips/tricks:

  • The TeX Book mentions (p 25) the use of ties (~) in the context of Thor's "A SHORT STORY" when typesetting Mr.~Drofnats:

    A good typist will use ties within names...

  • \emph or \textit provides a good example of when/why to use either \emph or \textit.

  • The contents of DO’s and DON’Ts when typesetting a document has some very relevant manual application of consistencies, including:

    • Put a tilde before references or citations, e.g., Jie~\cite{habit06}.
    • Differentiate between text comma and math comma, e.g., type for $x=a$, $b$, or~$c$ instead of for $x=a,b$, or $c$.
    • Write ellipsis using \ldots instead of three dots.
  • The l2tabu documentation also provides an interesting list of "do's and dont's".

Any more?

5
  • I'm assuming that the note about citations only applies if you are not using footnote citations, which you want to come right after the word? Or am I missing something?
    – Canageek
    Commented Sep 28, 2011 at 22:45
  • @Canageek: I would think so, otherwise it would probably have used \footcite.
    – Werner
    Commented Sep 29, 2011 at 5:02
  • A somewhat related question: Best practices references
    – Werner
    Commented Oct 7, 2011 at 23:30
  • Some related answers on things to avoid when using LaTeX via a "community poll": meta.tex.stackexchange.com/questions/1564/tex-community-polls/…
    – Werner
    Commented Nov 1, 2011 at 16:53
  • For large works, I create an extra document, a styleguide.
    – user282514
    Commented Feb 23, 2023 at 23:17

5 Answers 5

143

Define commands for common structures; for instance, even if keywords will be typeset with \textsf, it's better to define

\newcommand\keyword{\textsf}

and use \keyword{mykey}. This not only adds visual clues when writing and reading the TeX document, but makes possible to change the typographical aspect at once everywhere.

Similarly, define environments for common logical units that might deserve particular typographical treatment.

Put structured comments around things like \enlargethispage or \pagebreak used during the final revision (which often turns out not to be really definitive). Make liberal use of comments in general.

9
  • 6
    +1 for suggesting making "liberal use of comments in general". :-)
    – Mico
    Commented Oct 4, 2011 at 10:59
  • 12
    Thanks @egreg for "consistently" delivering valuable answers!
    – Werner
    Commented Dec 23, 2011 at 6:10
  • 2
    @HenriMenke There are two reasons: first, \newcommand is documented in the manual, \let isn't; second, if you change meaning to \textsf also \keyword will follow it.
    – egreg
    Commented Mar 23, 2014 at 16:37
  • 2
    @cfr Actually \newcommand* is even better. But it should be explained. ;-)
    – egreg
    Commented Sep 20, 2014 at 23:42
  • 4
    @cfr No, it's just a bit slower, but perhaps clearer. The “no argument” version better illustrates the concept of macro replacement.
    – egreg
    Commented Sep 21, 2014 at 9:17
57

For ellipses, do not only use \ldots, but also load the ellipsis package. Package description:

This is a simple package that fixes a problem in the way LaTeX handles ellipses: it always puts a tiny bit more space after \dots in text mode than before it, which results in the ellipsis being off-center when used between two words.

\documentclass{article}

% \usepackage{ellipsis}% Remove comment sign and compare

\begin{document}

\Huge

Some text \ldots\ and some more.

\end{document}

Note that ellipsis must be loaded after hyperref. (The ellipsis documentation doesn't mention this, but the hyperref README does.)

7
  • 2
    Also if you use the ellipsis package and want square brackets around the dots you should load the package with the mla option as in \usepackage[mla]{ellipsis}.
    – N.N.
    Commented Sep 29, 2011 at 7:15
  • 11
    I prefer another way: use the Unicode ellipsis character '…' (but not in math mode). This ellipsis is just as the font designer wanted, not artificially generated, and this makes text look a bit more consistent. One also can set up a proper sfcode for this character, if using \nonfrenchspacing. Commented Sep 29, 2011 at 7:32
  • Why do you need to force a space with \ after \ldots? Can you elaborate on that?
    – adn
    Commented Dec 8, 2011 at 4:43
  • I know this is a bit old, but: doesn't the ellipsis package provide (or redefine) the \dots command? Why are you then talking about \ldots? Are they somehow related?
    – mSSM
    Commented May 17, 2012 at 16:39
  • 1
    Is it really correct that you want the ellipsis centred between two words? Intuitively, I would have expected it to have slightly greater space on the right, although I'm not sure why.
    – cfr
    Commented Sep 20, 2014 at 23:32
40

There are some situations in spacing, where the author has to make TeX/LaTeX aware of an exception. Make a difference between 'full stop' and 'full stop after an abbreviation' as in this example:

I like BASIC\@. What about you?

The \@ enforces end-of-sentence period even if the precedent character was a capital letter, it is not part of an acronym. Also, I usually set a fixed space between the number and the unit, when a quantity is given, e.g.:

switching frequency of 1\ MHz

\ inserts a normal inter-word space.

10
  • 54
    I prefer using siuntix for typesetting numbers, eg. \SI{1}{\mega\hertz}. That makes it easier to change the style global and consistent.
    – Tobi
    Commented Sep 30, 2011 at 12:51
  • 1
    @Tobi: wasn't aware of that package... good idea! :)
    – Count Zero
    Commented Sep 30, 2011 at 12:55
  • 14
    @CountZero: Note that a space inserted with \ can be stretched and shrunk.
    – mhp
    Commented Sep 30, 2011 at 18:38
  • 3
    @mhp: Thanks, you're right about that one --- still, I don't really understand this. I'll rather post it as a question, so this page will not be cluttered with comments.
    – Count Zero
    Commented Oct 1, 2011 at 21:45
  • 1
    I always have trouble remembering the syntax for \@. Isn't there a more verbose but clearer alternative available? I am thinking something such as \dontEndASentenceHere? Commented Oct 31, 2012 at 21:52
29

I would add:

csquotes

Use csquotes rather than entering quotation marks manually. There are several ways to use the package. I tend to use the following in my preamble:

\usepackage[utf8]{inputenc}
\usepackage{csquotes}
   \MakeAutoQuote{‘}{’}
   \MakeAutoQuote*{“}{”}

The package will automatically switch from inner to outer quotes, at least for 2 levels of quotation marks. For example,

‘This is a quote which quotes ‘another quote’.’

produces

US style autoquotes

That is all very well if I'm writing for the other side of the Atlantic. But what if I'm writing on my own side?

\documentclass[british]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
  \MakeAutoQuote{‘}{’}
  \MakeAutoQuote*{“}{”}

\begin{document}

‘This is a quote which quotes ‘another quote’.’

\end{document}

will produce this:

UK style autoquotes

Similar support is available for a number of other languages. One advantage of this is that simply by changing the style in the preamble, I can easily change to the style of quotes required by a particular journal or publisher. I don't have to search and replace every occurrence of `...' with ``..'' in my text.

Not all languages supported by babel and polyglossia are supported by csquotes. Welsh is supported by babel, for example, but not by csquotes. Fortunately, welsh can be straightforwardly defined as an alias of british (see moewe's comment on my question about biblatex support for Welsh:

\documentclass[welsh]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\DeclareQuoteAlias{british}{welsh}
  \MakeAutoQuote{‘}{’}
  \MakeAutoQuote*{“}{”}

\begin{document}

‘Pwy sy'n gofyn ‘pwy sy'n gofyn?’?’

\end{document}

produces

Welsh quotes

In addition, csquotes and biblatex cooperate if used together, and csquotes also offers facilities for typesetting block quotations, quotations in foreign languages, quotations with citations, ellipses and more. For US English, for example, it also offers automated support for the illogical punctuation some publishers insist on (where the punctuation is moved inside the quotation marks even though it is not part of the material quoted).

Package Customisation

In addition to defining macros as egreg suggests, make liberal use of the support packages offer for creating custom commands and environments.

For example, if you use enumitem to customise lists, and want to use the same settings for several lists in a document or in several documents, rather than repeating the settings each time, use \newlist and \setlist so that you can tweak the settings in one place as required, ensuring consistency.

\documentclass{article}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{1}
\setlist[mylist]{label={Item \Alph*)}, font=\sffamily\bfseries, ref={item \Alph*}, wide}
\begin{document}

  This is an example of a customised enumeration environment which could be used repeatedly in one or many documents to ensure a consistent style:
  \begin{mylist}
    \item First
    \item \label{item:second}Second
  \end{mylist}
  Consider \ref{item:second}. Moreover, if you need the enumeration to increment consistently, you may also wish to use a further option:
  \begin{mylist}[resume]
    \item Third
  \end{mylist}

\end{document}

My list

Using the facilities offered by referencing packages such as fancyref or cleveref can ensure consistent cross-references, and packages such as geometry and fancyhdr can assist with consistent page layout.

Finally, if using TiKZ, use styles for the sake of both compact, readable code and consistency.

Common Preamble

If multiple documents should be typeset consistently because they are part of the same project, for example, use a single preamble containing all of the common packages and definitions. For example, define colours, page layout and general formatting here. Then \input{preamble} in each of the individual files. That way, the documents remain distinct and can be compiled separately but common customisation is managed in a single location.

10

There are also issues like the following:

In Czech typography, one-letter prepositions and conjuctions (v, s, z, k, o, u, a, i) should not be at the end of a line. Tildes are added automatically by the encxvlna package by Zdeněk Wagner and Petr Olšák. It needs the encTeX extension.

Also in Czech typography, for a word containing hyphen it is ideal to break the line at the hyphen, however in that case the hyphen should be repeated on the next line. For this one needs a macro which implements that logic (it is present in new version of babel package and there is also shorthand "= for it). But you still have to manually write "= instead of - at particular places.

My point is that as far as I know, there is no good solution for issues like this. Either one has to manually put additional marks into the text or use specialized TeX magic which is (at least for me) not flexible enough. The last and my favourite option is to write a preprocessor and establish additional level of abstraction. This is however non-trivial and time-consuming.

1
  • Using the special hyphens provided by babel is definitely a good idea. There is a host of them in the ngerman variant (which can be loaded to other languages, too).
    – Raphael
    Commented Dec 12, 2014 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .