7

It is often recommended to include \usepackage[T1]{fontenc}, but I have been hit by the following difference:

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
texttt: \texttt{-->}

verb: \verb+-->+ \end{document}

Without fontenc both render the same -->. But with fontenc the first is rendered as ->.

Are there other such differences to expect?

false
  • 289

1 Answers1

8

In my opinion, it was an oversight when the EC fonts were developed.

You can disable the ligatures (in pdflatex) with microtype.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{microtype}

\DisableLigatures[-,?,!,<,>]{encoding=T1,family=tt*}

\begin{document}

texttt: \texttt{--> --->}

verb: \verb+--> --->+

\texttt{?! ff fi fl ffi ffl << >>}

\end{document}

enter image description here

Without the \DisableLigatures line you'd get

enter image description here

With XeLaTeX or LuaLaTeX there is no problem, because the monospaced font is loaded without TeX ligatures enabled.

\documentclass{article}
\usepackage{fontspec}

\begin{document}

texttt: \texttt{--> --->}

verb: \verb+--> --->+

\texttt{?! ff fi fl ffi ffl << >>}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thank you! Does it make a difference where I add the line \usepackage[scaled]{beramono} so before or after? (I cannot see any, but then...) – false Sep 16 '23 at 07:31
  • @false beramono has no “hyphen ligatures”, as far as I can see. Depending on your needs, you may want to disable the “guillements ligatures”, though. – egreg Sep 16 '23 at 08:49