Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In many fonts, the digit 1 contains a lot of empty space on its left side. Maybe this is desirable inside a number like 512, but it looks wrong to me when the 1 appears at the beginning of a word, as in the example below. Is there any way to have LaTeX automatically detect when 1 is at the beginning of the word and remove the unwanted padding?

numeral-one

\documentclass[12pt]{article}
\begin{document}
\noindent
The article appears in vol.\ 16 of the encyclopedia. \\
The article appears in vol.\ sixteen of the encyclopedia.
\end{document}
share|improve this question
1  
Note that the period is not relevant to the question. The same issue arises without a period (although it's a bit harder to notice). –  Noah Oct 3 '12 at 2:12
    
If the digit 1 in your font has the same fixed width as the other digits, it may appear there's more space between the fulstop and the digit. –  Marc van Dongen Oct 3 '12 at 7:41
    
Looks like the font has a kemed “1”. –  Konrad Rudolph Oct 3 '12 at 10:21
1  
@KonradRudolph -- many fonts set up for use with tex, and certainly computer modern, have digits that are intended for use in tabular material, hence are monospace. digits for use in text, whether "lining" (all the same height) or old-style, have widths according to their shapes; this is most obvious for "1". no kerning involved. –  barbara beeton Oct 3 '12 at 12:23
1  
@KonradRudolph -- nope, lining refers only to the height. you're thinking of "proportionally spaced" digits. (there may be a more type-centric term that i've momentarily forgotten.) let l = lining, o = old-style, m = monospace/tabular, p = proportional. a really full metal font has four sets of digits: lm, lp, om, op; this set of alternatives is coming back to us with opentype, and i'm glad. –  barbara beeton Oct 3 '12 at 12:33
show 2 more comments

2 Answers 2

up vote 23 down vote accepted

The problem is that the digits are usually set with the same width, thus alignments in tables look nicer this way. However, the digit 1 is rather slim, thus it has large side bearings:

\documentclass[12pt]{article}

\pagestyle{empty}
\setlength{\parindent}{0pt}
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.1pt}

\begin{document}
  \Huge
  \fbox{1}\\
  \fbox{2}
\end{document}

1 and 2 boxed

The distance between the left border and the start of the character (left side bearing) is much larger in case of 1 than for digit 2.

Finding the right fonts is the tricky part. The following example uses LuaLaTeX in order to use Latin Modern as OpenType font, where proportional numbers are available as font feature.

\documentclass[12pt]{article}
\usepackage{fontspec}


\begin{document}
\begingroup

  \noindent
  The article appears in vol.\ 16 of the encyclopedia. \\
  \fontspec[Numbers=Proportional]{Latin Modern Roman}%
  The article appears in vol.\ 16 of the encyclopedia.\\
  The article appears in vol.\ sixteen of the encyclopedia.

\endgroup

\begingroup

  \setlength{\fboxsep}{0pt}
  \setlength{\fboxrule}{.1pt}
  \Huge
  \noindent
  \fbox{1}\\
  \fontspec[Numbers=Proportional]{Latin Modern Roman}%
  \fbox{1}\\
  \fbox{2}

\endgroup
\end{document}

Result

share|improve this answer
    
Thanks, that's good to know that certain fonts support this feature! However at the moment the choice of font is out of my control, so this isn't an option. –  Noah Oct 3 '12 at 2:01
    
I'm choosing this as my accepted answer, since from the other answers it's clear that what I wanted to do isn't possible in a general way. –  Noah Oct 3 '12 at 14:01
    
Would there be any way to use XeTeX or LuaLaTeX to decrease the left-side bearing of 1 in an OpenType font that doesn't support proportional numbers (e.g. Times New Roman)? It looks like it should be possible from this question, but I can't see how to do it from the fontspec docs. –  Noah Oct 3 '12 at 14:25
add comment

If you're willing to insert a "hook" of sorts, the you can certainly pick up whether a period is followed by a number 1:

enter image description here

\documentclass[12pt]{article}
\makeatletter
\def~{\nobreakspace\@ifnextchar1{\kern-.2em}{}}
\makeatother
\begin{document}
\noindent
The article appears in vol.~16 of the encyclopedia. \\
The article appears in vol.~26 of the encyclopedia. \\
The article appears in vol.~sixteen of the encyclopedia.
\end{document}

The use of a tie keeps vol. and the subsequent numeral together, which is a good thing. For example, ending a line with vol. would lead the reader to believe that the sentence has ended prematurely, and could cause a lack of flow.

share|improve this answer
    
Thanks, this works well if I know it's after a period. But is there a way to decrease the space before any word beginning with 1, regardless of whether there's a period and a tie? –  Noah Oct 3 '12 at 2:10
    
Ideally, I'm looking for a solution that would catch things in my bibliography like vol.~\bibinfo{volume}{14}, which only later gets expanded to vol.~14. –  Noah Oct 3 '12 at 2:27
    
Related to my answer: Avoiding line break before number –  Werner Oct 3 '12 at 3:03
1  
@Noah No, it isn't possible: it's really a font related question. The digit 1 can reveal much later than the moment in which the spacing decisions are made; if it is the first item in a box, then no macro based method can work. It might be possible to cope with a limited number of cases, though, but the amount of necessary work is unpredictable. –  egreg Oct 3 '12 at 9:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.