0

With this code:

\documentclass{minimal}
\usepackage[a4paper,showframe]{geometry}
\begin{document}
\noindent
\sffamily
Foo\\
\fontsize{24}{24}\selectfont
Bar
\end{document}

I get this output:

enter image description here

How can I left align the two lines?

1
  • TeX doesn't know the width of the glyphs, only the one of the surrounding boxes. You'll have to align them manually, if I'm not mistaken.
    – Skillmon
    Commented Oct 26, 2017 at 11:28

1 Answer 1

1

TeX doesn't know the width of a glyph of a font. It only knows the width of the surrounding box. If you enclose the character in a \fbox you can see, how much TeX knows about the two glyphs you want to align:

\documentclass{minimal}
\usepackage[a4paper,showframe]{geometry}
\fboxsep=-\fboxrule
\begin{document}
\noindent
\sffamily
\fbox{F}oo\\
\fontsize{24}{24}\selectfont
\fbox{B}ar
\end{document}

enter image description here

As you can see, the characters are aligned as far as TeX is concerned, therefore you'll have to align them manually, e.g. with:

\documentclass{minimal}
\usepackage[a4paper,showframe]{geometry}
\begin{document}
\noindent
\sffamily
Foo\\
\fontsize{24}{24}\selectfont
\hspace*{-0.12ex}Bar
\end{document}

enter image description here

2
  • Thank you for the explanation! So the answer is that it's not possible to align the glyphs? Commented Oct 26, 2017 at 11:35
  • @GiovanniLovato at least not automatically.
    – Skillmon
    Commented Oct 26, 2017 at 11:38

You must log in to answer this question.

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