2

This MWE

\documentclass{article}
\usepackage{xparse}
\begin{document}    
\NewDocumentCommand{\myVerbatim}{v}{#1}

\myVerbatim|This is some text, which can contain $\sin(x)$ or code or $$|

\verb|This is some text, which can contain $\sin(x)$ or code $$|
\end{document}

Produces, using lualatex, this

Mathematica graphics

I thought they should come out the same. Why are they different?

From manual

Mathematica graphics

TL 2015

  • 1
    \verb is a typesetting command: a v-type argument is about 'grabbing' stuff, what you do with it is down to you – Joseph Wright Jun 3 '16 at 9:31
2

The manual doesn't say that a font selection is done when delivering the argument after it has grabbed “in a way similar to \verb” just because it doesn't happen in the first place. So

\NewDocumentCommand{\myVerbatim}{v}{\texttt{#1}}

will emulate \verb (but \verb does some more things).

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.