# Tag Info

## New answers tagged verbatim

2

I extended the answer from alexis to cover more formats: normal format (diff), unified format (diff -u), context format (diff -c) and diffs from Git (git diff): \lstdefinelanguage{diff}{ sensitive=true, % diff command line morecomment=[f][\color{gray}][0]{diff}, % commit identifiers for git diff morecomment=[f][\color{gray}][0]{index}, % hunk ...

2

One possible work around is to use a temporary file. First you need a macro to write to the file (\jobname.tmp was used here) and read it twice using the regular and the listing input commands: \usepackage{listings} \newwrite\tempfile \newcommand{\example}[1]{ \immediate\openout\tempfile=\jobname.tmp \immediate\write\tempfile{#1} ...

4

I am not entirely sure that I understood what you want. However, your MWE can easily be achieved with xparse and its v type argument: \documentclass{article} \usepackage{qrcode,xparse} \NewDocumentCommand{\script}{v}{% \texttt{#1} \qrcode{#1}% } \begin{document} \script{test} \script{&$\#$} \end{document} Keep in mind, though, that now since now ...

2

Use \begin{frame}[fragile]. This option is needed when the content contains verbatim.

3

beamer has the columns environment, makes sense to use that I think. Note that you need the [fragile] option to the frame in order to use verbatim and the like. \documentclass{beamer} \begin{document} \begin{frame}[fragile] \begin{columns}[t] \column{0.5\textwidth} \begin{verbatim} SELECTION test1 JET_N 25000 >= 1 JET_N 25000 >= 2 JET_N 25000 >= ...

0

Just to add on to what @TH mentioned, \texttt also works well inside equation/eqnarray environments and TikZ code. \verb (in its primitive form) doesn't work very well in such cases.

4

To get verbatim content inside the align* environments, my verbatimbox package can help. \documentclass{article} \usepackage{amsmath,verbatimbox} \begin{document} \begin{myverbbox}{\lineA}\int \sin x\,dx\end{myverbbox} \begin{myverbbox}{\lineB}\int{\sin x}\,dx\end{myverbbox} \begin{align*} \int \sin x\,dx && \lineA\\ \int{\sin x}\,dx && ...

2

You can't use \verb inside align*, just like in the argument to any other command; align is a special environment that reads its contents before starting typesetting and this has the consequence that \verb is not allowed. If you want to make examples of input and output, you can use array: \documentclass{article} \usepackage{array,booktabs} ...

2

You can use the verbatim package to define a new environment that defines a character to enclose the footnote text. \documentclass{article} \usepackage{verbatim} \textheight=3cm % just not to waste space \newcommand{\vfchar}[1]{% % the usual trick for using a "variable" active character \begingroup\lccode~=#1 \lowercase{\endgroup\def~##1~}{% % ...

4

Here is a version without the use of packages (i.e., works in plain verbatim environment). I make ? (or any char of your choosing) active and employ ! (or any char of your choosing) as a delimiter. With this syntax, ?!My footnote! is the equivalent of \footnote{My footnote}. \documentclass{article} \textheight=1.5in\relax% FOR THIS MWE ONLY ...

8

You have to do \usepackage{verbatim} \newenvironment{listing} {\minipage{\linewidth}\verbatim} {\endverbatim\endminipage} There's almost the same example on page 3 of the package documentation, see the definition of the fred environment. Note that \begin{minipage} executes (among other things) \minipage and similarly \end{minipage} executes ...

11

listings provides the possibility to escape to LaTeX inside a listing, see section 5.12 Escaping to LaTeX of the manual for details. The basic idea is to set an escapechar which switches to LateX and back: \documentclass{article} \usepackage{listings} \begin{document} \begin{lstlisting}[basicstyle=\ttfamily,columns=fullflexible,gobble=2,escapechar=ß] ...

4

I would do this: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \newcommand\textinput[1]{{% \catcode\\$=12 \catcode\&=12 \catcode\_=12 \catcode\^=12 \catcode\#=12 \catcode\%=12 \catcode\~=12 \input{#1}}} \begin{document} \section{zzz} \textinput{zzz.txt} \end{document} with input file aaa & bbb is 5% of ...

6

You can do this with \newminted command \documentclass{article} \usepackage{minted} \newminted[lstlisting]{scala}{} \begin{document} \begin{lstlisting} #include <stdio.h> #define N 10 /* Block * comment */ int main() { int i; // Line comment. puts("Hello world!"); for (i = 0; i < N; i++) { puts("LaTeX is also ...

5


16

\documentclass{article} \usepackage[T1]{fontenc} \setlength\textwidth{20em} \begingroup \makeatletter \gdef\plaintext{\let\do\@makeother\dospecials\catcode32=10\relax\xplaintext} \catcode\!=0 !catcode\\=12 !catcode{=12 !catcode}=12 !catcode(=1 !catcode`)=2 !long!gdef!xplaintext#1\end{plaintext}(% #1!end(plaintext)) !endgroup \begin{document} ...

6

This approach uses \detokenize, but wraps it in a paragraph parser, which will format lines and indeed paragraphs in a verbatim-like manner. EDITED to incorporate a trap for the % character, taking a nod from David's approach. However, there is (at least) one area where it will break: unmatched braces {}. However, this limitation may or may not pose an ...

0

I wouldn't reinvent the wheel. ;-) \documentclass{article} \usepackage{fancyvrb} \begin{document} \begin{VerbatimOut}{\jobname-later.tex} \begin{verbatim} foo() { } \end{verbatim} \end{VerbatimOut} Something \input{\jobname-later} \end{document} One can use the infrastructure of fancyvrb to define VerbatimOutAppend so that the file is closed ...

Top 50 recent answers are included