[Tex/LaTex] Nicely force 66 characters per line

koma-scriptmacrosmarginsmemoirpackages

I would like to have "something" (a package, a trick, a macro, …?) that makes it possible for me to nicely play with the margins (or the layout) in order to set the average or typical number of characters per line.

Ideally, this "system" would help me keep this ratio (66, 2.5 alphabets, or any other number I choose/input) independent from changes in font families (such as with the use of the package pslatex or txfonts for example), in font sizes (with a 10pt or 12pt class option for example).

I've looked around a bit, and I kind of understood, that using KOMA-Script classes or the memoir class may be part of a solution, be I would prefer not (especially because I have never used any so far).

An important point for me is that the whole proportions or principles of the original layout must be kept. For example, if there was a set ratio between left and right margins, then, just playing around with one margin or with textwidth/linewidth would not satisfy me.

Why I'd like to do this? Because I like to use the pslatex package, but this put the average number of charaters per line from about 65 without to about 75+ with.

Note, I have already gone or skimmed through:

And, also there may be answers there, I couldn't (too easily) find them.

Best Answer

The statement about 2.5 times the length of the lowercase alphabet is just an indication. However you can play with geometry:

\documentclass{book}

%%\usepackage{newtxtext}
\newlength{\alphabet}
\settowidth{\alphabet}{\normalfont abcdefghijklmnopqrstuvwxyz}

\usepackage{geometry}
\geometry{textwidth=2.5\alphabet,hmarginratio={2:3}}

\begin{document}
\the\textwidth
\end{document}

This will use a ratio for the margins as indicated (2:3 is actually the default, in twoside mode). Well behaved font packages should work correctly.

With the default fonts I get a textwidth of 318.96pt, while with newtxtext I get 298.58pt (with mathptmx the result is 298.57pt).

Notice that pslatex is a very obsolete package and that its descendant mathptmx is rather inadequate for serious typesetting involving math. If you don't need mathematics, other choices based on (Linotype) Times Roman are

  • newtxtext (based on txfonts, but with corrected metrics)

  • tgtermes

The former has the companion math package newtxmath.

You can choose whatever ratio you prefer for the margins. It's customary, in twoside printing, to have the outer margin wider than the inner one. If you want to automatize the choice between oneside printing (equal margins) and twoside, then

\geometry{textwidth=2.5\alphabet}
\makeatletter
\if@twoside
  \geometry{hmarginratio={2:3}}
\else
  \geometry{hmarginratio={1:1}}
\fi
\makeatother

could be used. The options for geometry can be given in distinct \geometry commands. Don't forget to specify the paper size (you can do it either in \geometry or as a class option).

You can also test the loaded class:

\makeatletter
\geometry{hmarginratio={1:1}} % fallback

\@ifclassloaded{book}
 {
  \if@twoside
    \geometry{hmarginratio={2:3}}
  \else
    \geometry{hmarginratio={1:1}}
  \fi
 }{}

\@ifclassloaded{article}
 {
  \if@twoside
    \geometry{hmarginratio={4:2}}
  \else
    \geometry{hmarginratio={1:1}}
  \fi
 }{}
\makeatletter

(the setting 4:2 is just by way of example).

However there's no "catch all" format: what you finally choose for a document depends on the document itself.


How to set the horizontal margin ratio to be equal to that fixed by the class? This is a bit difficult, because the standard setting uses a different model than geometry.

\documentclass{article}
\usepackage{newtxtext}
\usepackage{geometry}

\newlength{\alphabet}
\sbox0{\normalfont abcdefghijklmnopqrstuvwxyz}
\setlength{\alphabet}{\wd0}

\makeatletter
\begingroup
\dimendef\innermargin=\z@
\dimendef\outermargin=\tw@
\innermargin=\dimexpr\oddsidemargin+1in+\hoffset\relax
\outermargin=\dimexpr\paperwidth-\innermargin-\textwidth\relax
\outermargin=.002\outermargin
\innermargin=2\innermargin
\count@=\innermargin
\divide\count@ \outermargin
\xdef\standardhmarginratio{\number\count@:1000}
\endgroup

\geometry{textwidth=2.5\alphabet,hmarginratio=\standardhmarginratio}

\begin{document}

text width = \the\textwidth

horizontal margin ratio = \standardhmarginratio

\end{document}

With the article class we get 1000:1000, with book (twoside mode) the result is 667:1000 that's, for all practical purposes, 2:3.