0

Continuing How to letter space (German) abbreviations automatically and http://tex.stackexchange.com/a/134856 , some of us tend to typeset a usual or a thin space in abbreviations and write, e.g.,

d.\@ h, d.\ h., d.\,h., z.\@ B, z.\ B, z.\,B.

Though DIN 5008:2011 (now superseded; can anyone consult an update?) typesets a usual unbreakable space there without mentioning any width changes at all, the example z.°B. they provide is typeset in a monospace font. However, much more often we use a proportional font, so we'd probably also consider it nicer (as many folks here at TeX.SE) to slightly decrease the width of the nonbreakable space inside the abbreviation. Some folks say it should be half the width of the normal space; cf. http://www.master-bachelor-korrektur.de/abstaende.php .

Using cmr10 with the length of space being 3.33pt, we therefore obtain

d.\kern1.665pt h., z.\kern1.665pt B.,

which is close enough to

d.\kern.16667em h., z.\kern.16667em B.

or

d.\,h., z.\,B.

in text mode. You may alternatively take some other value in the interval [min{thin space, half space}, regular space[ if you prefer to be closer to DIN5008:2011; the exact value probably doesn't matter much for the point of the question.

Now, when typesetting really lots of text, you sooner or later stumble upon two issues:

A. with fixed-width \kernnumber, your abbreviations sometimes look too wide or too narrow compared to the rest of the line, and

B. in narrow columns, you'd sometimes like to avoid text running into the right margin or the last line of a para ending up too empty or unfavorable hyphenations of words elsewhere in the paragraph.

Issue A can be solved by adding a stretch and shrink components to the intra-abbreviation space, and issue B by introducing a nonmaximal penalty:

d.\penalty5000\hskip.16667em plus.08333em minus.08333em h., z.\penalty5000\hskip.16667em plus.08333em minus.08333em B.

This raises two questions:

  1. Above, 5000 is a value out of nowhere, being 50 % of \@M without us being able to explain why it's \@M/2 and not \@M/3 or 2\@M/3 or simply 1. What would be a good generic value or range of values (smaller than my current guess, which is the interval [1, 9999]) for the penalty?

  2. Above, we took roughly 50 % of the natural width for the stretch and shrink attributes. Again, 1/2 is out of nowhere — it could have also been any other value in ]0,1[, such as 1/3 or 2/3. Any better-informed choices for the percentages for the stretch and shrink attributes?

Independent thereof and following David's comment Any special care needed if a period inside an abbreviation is followed by a \hskip or a \hspace? , we'd like to avoid the absolute values in pt or em, and instead, we'd like to use values relative to the space-related font dimensions. Thus:

  1. How to express
\hskip.5*\fontdimen2 plus.5\fontdimen3 minus.5\fontdimen4

in LaTeX correctly? Of course, if you don't like 1/2, feel free to take some other percentage provided you have a good explanation for it. Alternatively, you may take other linear combinations of \fontdimen2, \fontdimen3, and \fontdimen4 for the three parameters if you feel the need and can explain it.

0

2 Answers 2

3

For 3

\fontdimen takes two arguments, the parameter number and the font to take the parameter from. \font returns the current font so \hskip.5\fontdimen2\font plus.5\fontdimen3\font minus.5\fontdimen4\font


For 1

it depends what you are trying to prevent by adding the penalty. TeX will try to find linebreaks to minimize total badness, so the value at that point can not be considered in isolation, you need to consider what happens if the linebreak is not taken there, typically some white space gets stretched to allow a sub-optimal breakpoint so that stretching will incur a badness value and you need to make the penalty of breaking your abbreviation greater then the penalty of stretching the white space if the penalty is to have an effect.

enter image description here

In the first test you see that the breakpoint between the !! is quite easily avoided. It is taken if the penalty is 10 but a penalty as low as 20 is already enough to prevent a break at that point.

In the second test it is harder to avoid a break at that point even the maximum non forcing penalty of 9999 is not enough.

So there are no definite rules you need to choose what you want to prevent and how much you are willing to tolerate the badness produced by suboptimal alternatives

\documentclass{article}

\begin{document}
3) \hskip.5\fontdimen2\font plus.5\fontdimen3\font minus.5\fontdimen4\font X

\noindent X\dotfill X

\def\test#1{\par$#1$\par
  aaaaaaaaaaaaaaaaaaaaaaaaaaaa aaa a a a a a a4 a a a a a a a7 a a a a 8 aa!\penalty#1\,! bbb}

\test{-10000}
\test{10000}
\test{20}
\test{10}
\test{00}



\noindent X\dotfill X

\def\test#1{\par$#1$\par
  aaaaaaaaaaaaaaaaaaaaaaaaaaaa aa aaa aaa aa aa aaaaaaaaaaaaaaaaaa7  aa!\penalty#1\,!bbb bbbbbb}

\test{-10000}
\test{10000}
\test{9999}
\end{document}

For 2

it depends a bit on cultural expectations of punctuation of abreviations, but I would probably allow less shrink than stretch. The space is already narrow so in tight lines if you allow it to halve it may effectively look like no space at all. Whether A.B. looks right with no clearly visible space depends on what you (or your readers) expect it to look like.

3
  • Thank you! Upon experimenting, it turned out I don't understand certain basics (or LaTeX does not correspond to The TeXbook), so I had to ask another question first: tex.stackexchange.com/questions/708671 . After understanding what goes on there, I'm going to return to the issue here.
    – AlMa1r
    Commented Feb 4 at 1:03
  • As for the penalty value, I understand it cannot be generically set and must be set on a case-by-case basis. At the same time, your 10, 20, and 9999 examples show together that if we choose to allow for line breaks inside abbreviations at all, low values (probably below \hyphenpenalty=50 so that we split text semantically, i.e., between the words rather than inside the words) should be considered.
    – AlMa1r
    Commented Feb 4 at 4:46
  • @AlMa1r yes latex standard classes use the penalty values 0, 51, 151, 301, 10000. for \linebreak[0,1,2,3,4] . For abbreviations I would probably use 10000 or 9999 that is never break or allow a break only if absolutely every other possibility is infinitely bad. 5000 just show indecision: why allow that much stretch to avoid a break but not more.... Commented Feb 4 at 8:31
2

I don't think you want a line break in the middle of such an abbreviation, which would be possible with \penalty5000.

You can get uniformity using a command:

\documentclass{article}

\ExplSyntaxOn

\NewDocumentCommand{\abk}{m}
 {
  \tl_head:n { #1 } % the first letter
  \exp_args:Ne \tl_map_function:nN { \tl_tail:n { #1 } } \aim_add_space:n
  .\@
 }

\cs_new_protected:Nn \aim_add_space:n
 {
  .\@\nolinebreak
  \skip_horizontal:n { ( \fontdimen2\font plus \fontdimen3\font minus \fontdimen4\font)*2/3 }
  #1
 }

\ExplSyntaxOff

\begin{document}

\abk{dh}
\abk{zB}

\abk{wxyz}

\makebox{word word \abk{zB} word word}

\makebox[1.3\width][s]{word word \abk{zB} word word}

\makebox[0.95\width][s]{word word \abk{zB} word word}

\end{document}

Here the normal interword space is reduced to 2/3, using a skip expression. Experiment with the factor.

enter image description here

For completeness the command might check whether \spaceskip is nonzero and use it in case it is.

\documentclass{article}

\ExplSyntaxOn

\NewDocumentCommand{\abk}{m}
 {
  \tl_head:n { #1 } % the first letter
  \exp_args:Ne \tl_map_function:nN { \tl_tail:n { #1 } } \aim_add_space:n
  .\@
 }

\cs_new_protected:Nn \aim_add_space:n
 {
  .\@\nolinebreak
  \dim_compare:nTF { \spaceskip > 0pt }
   { 
    \skip_horizontal:n { \spaceskip*2/3 }
   }
   { 
    \skip_horizontal:n { (\fontdimen2\font plus \fontdimen3\font minus \fontdimen4\font)*2/3 }
   }
  #1
 }

\ExplSyntaxOff

\begin{document}

\abk{dh}
\abk{zB}

\abk{wxyz}

\makebox{word word \abk{zB} word word}

\makebox[1.3\width][s]{word word \abk{zB} word word}

\makebox[0.95\width][s]{word word \abk{zB} word word}

\setlength{\spaceskip}{1em plus 1em minus 0.5em}

\makebox{word word \abk{zB} word word}

\makebox[1.3\width][s]{word word \abk{zB} word word}

\makebox[0.95\width][s]{word word \abk{zB} word word}

\end{document}

enter image description here

3
  • Thank you! Upon experimenting, it turned out I don't understand certain basics (or LaTeX does not correspond to The TeXbook), so I had to ask another question first: tex.stackexchange.com/questions/708671 . After understanding what goes on there, I'm going to return to the issue here.
    – AlMa1r
    Commented Feb 4 at 1:04
  • As for penalty: it is true that you usually don't wish to have a line break, and at the same time in rare cases (that's why I spoke about lots of text) you do wish it because something else goes wrong otherwise (e.g., the text goes into the non-printable margin specified by the publisher, or a word elsewhere in the paragraph is hyphenated unfavorably). As for 2/3: any rationale behind it? By the way, according to \showoutput, the shrink attribute seems to be unaffected by 2/3, staying at 1.11111.
    – AlMa1r
    Commented Feb 4 at 1:35
  • 1
    @AlMa1r Sorry for the typo \fontdimen3 instead of \fontdimen4. About 2/3: I chose a fraction and told you to experiment. I'd simply use a normal space (with no line break allowed).
    – egreg
    Commented Feb 4 at 8:56

You must log in to answer this question.

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