11

This code:

\documentclass{ltugboat} 
\usepackage{tcolorbox}

\begin{document} 
    \begin{verbatim}[\small]
    \documentclass{article}
    \usepackage{tikzduck}
    \begin{document}
        \begin{tikzpicture}
            \duck
        \end{tikzpicture}
    \end{document}
    \end{verbatim}
\end{document}

produces this output:

enter image description here

whereas if you comment out \usepackage{tcolorbox}, the output is correct:

enter image description here

  • 5
    tcolorbox loads the verbatim package and this redefine verbatim. Probably it would be the best to ask @barbarabeeton how to handle this. – Ulrike Fischer Aug 10 '17 at 21:15
11

The [\small] is a feature of ltugboat verbatim. If you use a different verbatim, you have to get rid of it. At least, I can't picture a different solution, sorry.

Instead, you can use something like

{\small \begin{verbatim}
...
\end{verbatim}
}

But I would guess you already knew that.

  • I knew about that but it didn't come to my mind! Thank you! – CarLaTeX Aug 11 '17 at 2:50
  • 3
    It should be {\par\small\begin{verbatim}, otherwise \small will have effect on the paragraph before the verbatim material, unless a blank line is added in between. – egreg Aug 11 '17 at 9:04
5

I don't know how much tcolorbox relies on verbatim as defined by the homonym package that it loads, so something like

\documentclass{ltugboat}

\let\ltverbatim\verbatim
\let\ltendverbatim\endverbatim

\usepackage{tcolorbox}

\let\verbatim\ltverbatim
\let\endverbatim\ltendverbatim

may possibly yield problems when embedding verbatim material in tcolorbox environments.

A different approach is to use fancyvrb for your verbatim (non tcolorbox) material:

\documentclass{ltugboat}

\usepackage{tcolorbox}
\usepackage{fancyvrb}

\usepackage{lipsum}

\begin{document}

\lipsum*[2]
\begin{Verbatim}[fontsize=\small]
\documentclass{article}
\usepackage{tikzduck}
\begin{document}
  \begin{tikzpicture}
    \duck
  \end{tikzpicture}
\end{document}
\end{Verbatim}
\lipsum[3-5]

\end{document}

(avoid indenting verbatim). You can also set \small size by default with \fvset{fontsize=\small} in the preamble.

enter image description here

  • Thank you, yours is a very good solution! However, I still prefer to use Karl Berry's one because he is the manager of ltugboat documentclass. I'll look at TUGboat to see which is the standard for indentation. Ciao :) – CarLaTeX Aug 11 '17 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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