1

Is there a way to disable LaTeX's transformation of all double quotes e.g. '' `` << >> into formatted double quotes when using the verbatim package in conjunction with fontenc and redefining \verbatim@font such as:

\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{verbatim}

\makeatletter
  \renewcommand{\verbatim@font}{\fontsize{10pt}{12pt}\selectfont\ttfamily}%
\makeatother
\newenvironment{code}
  {\topsep=0pt\partopsep=0pt\endgraf\verbatim}
  {\endverbatim}

\begin{document}

\begin{code}
0x3333 << 1
\end{code}

\end{document}

The above turns << into a formatted french quote. If I don't use the fontenc package, or if I don't redefine \verbatim@font then it displays ok. For my document, I want to redefine the font (mainly to have better granularity than \small, \tiny etc) and I use the fontenc package because other parts of the document otherwise display wrong fonts.

Can I disable double quotes inside \verbatim or globally?

I could also ditch the verbatim package, but I want to define a command around verbatim text, and you can't do that by default.

It all works apart from those pesky quotes ... any help will be appreciated

Thanks in advance.

3
  • 3
    Please provide a complete small document that shows the problem (all questions should have such an example). What you describe is not the default behaviour, so it depends how you have defined < Commented Feb 28, 2015 at 13:03
  • Welcome to TeX.SX!
    – Mico
    Commented Feb 28, 2015 at 13:04
  • You're right. I edited the question and provided a full example. The problem manifests itself in conjunction with the fontenc package and redefining \verbatim@font. Any ideas to prevent the formatting of << ?
    – Bogdan
    Commented Feb 28, 2015 at 14:21

2 Answers 2

2

Doh, I forgot to RTFM! It's in the manual section 3.2 which discusses \verbatim@font

To fix my problem, change the redefinition of \verbatim@font to the following:

\makeatletter
  \renewcommand{\verbatim@font}{\fontsize{10pt}{12pt}\selectfont\ttfamily
  \hyphenchar\font\m@ne
  \let\do\do@noligs
  \verbatim@nolig@list}
\makeatother
2
  • yes if you redefine verbatim not to do verbatim, it stops doing verbatim +1 glad you got it working;-) Commented Feb 28, 2015 at 14:44
  • Indeed. Not enough coffee today.
    – Bogdan
    Commented Feb 28, 2015 at 15:45
1

TeX-style ligatures for character sequences such as << and >> are enabled in T1-encoded fonts even for monotype font faces. The following remedy should work: Insert the instructions

\usepackage{microtype}
\DisableLigatures{encoding = T1, family = tt* }

in the preamble.

Loading the microtype package may be a good idea in any case...

1
  • Thanks for this. The microtype package is required for \DisableLigatures. I wanted a solution without having to use extra packages, but this is useful as it disables ligatures for all tt* fonts, including inline (text) which is quite handy for my current use case.
    – Bogdan
    Commented Feb 28, 2015 at 15:43

You must log in to answer this question.

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