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?

1 Answer 1

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

2
  • 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
    Commented Sep 16, 2023 at 7: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
    Commented Sep 16, 2023 at 8:49

You must log in to answer this question.

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