# Tag Info

2

You can use \defverbatim{\foo}{\begin{verbatim}...\end{verbatim}} \documentclass{beamer} \begin{document} \begin{frame}[fragile] \defverbatim{\testslide}{\begin{verbatim}test slide 1 $E=mc^2$\end{verbatim}} \only<1>{% \testslide } \only<2>{ test slide 2 } \end{frame} \end{document}

3

You can't have verbatim-like environments in the arguments to \ifthen. But you can use the primitive conditionals. \documentclass{article} \usepackage{listing} \usepackage[framed]{matlab-prettifier} \newcounter{ctr} \setcounter{ctr}{1} \lstnewenvironment{myMP} {\lstset{style={Matlab-editor}}} {} \begin{document} \ifnum\value{ctr}=1 \begin{myMP} a = 1 ...

1

Here, I save the listing in a temporary \vbox, and only conditionally print it out. \documentclass{minimal} \usepackage{ifthen} \newcounter{ctr} \setcounter{ctr}{1} \usepackage{listing} \usepackage[framed]{matlab-prettifier} \lstnewenvironment{myMP}{% \lstset{style={Matlab-editor}}% }{} \begin{document} \setbox0=\vbox{% \begin{myMP} ...

2

You could use cprotect, but you should think twice before using \verb when, perhaps,\texttt might suffice. \documentclass{article} \usepackage{xcolor,cprotect} \newcommand{\test}[1]{\textcolor{blue}{#1}} \begin{document} This works \verb+\num{6.022e-23}+ \cprotect\test{This is a test of a \verb+\num{6.022e-23}+} \end{document} If you have several ...

2

As I commented, \verb can neither appear in a macro definition nor argument. However, depending on your need, this may suffice. One saves a verbbox in advance, and can pass that as an argument. \documentclass{article} \usepackage{xcolor,verbatimbox} \newcommand{\test}[1]{{\color{blue}#1}} \usepackage{siunitx,booktabs} \begin{document} This works ...

0

If you do not have a # character in your file but still having the same error message, than do the following: 1) delete the .aux and the .bbl files in your folder 2) Recompile This is the only thing that worked to me. Hope it helps !

19

The different is that \verb is an inline verbatim environment so that everything inside it is taken literally, even what would otherwise be considered a command. This also happens to use a monospace font because it is usually use to insert some codes (so that special characters don't pose any issue). On the other hand, \tt (and you really should be using ...

2

If you don't need commands in the text to typeset, a simplified version of jfbu's macros is available. It's also easy to turn the environment into an “input” type macro. As jfbu's macros, this code relies on using T1 encoded fonts. \documentclass[a4paper]{article} \usepackage{geometry} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \makeatletter ...

5

You don't need a package for this. The update at bottom of answer is for slightly more complicated coding which requires \end{myverbatim} and not only \end{myver to decide that the end of the environment has been hit. \documentclass[a4paper]{article} \usepackage{geometry} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \makeatletter \catcode\{ 12 ...

Top 50 recent answers are included