Tag Info

Hot answers tagged verbatim

10

The package fancyvrb has the enhanced Verbatim environment, and the key xleftmargin: \documentclass{article} \usepackage{fancyvrb} \begin{document} \thispagestyle{empty} \noindent A non-verbatim line \begin{Verbatim}[xleftmargin=.5in] Some verbatim lines \end{Verbatim} \noindent Another line \end{document} Moreover, you can redefine the standard ...

9

(it seems this works everywhere apart from acrobat reader) This is based on the example by @DavidCarlisle. The cmtt visible space character seems to be labelled differently in different cmtt variants. For cm-super (which is loaded here when I use \usepackage[T1]{fontenc}), the respective character is named uni2423 which seems to cause problems with evince ...

8

listings offers these commands: \lstinline -- for code snippets (similar to \verb but can highlight code) \lstlisting -- Environment where you can put your code in display mode. \lstinputlisting -- for including standalone files. Here is an example: \documentclass{article} \usepackage{filecontents} \begin{filecontents*}{filename.java} public class ...

6

You have to issue \theverbbox in order to print the verbatim text. However, the verbbox environment shouldn't be inside center. I also add how to do it with fancyvrb and its BVerbatim environment. I also use \url for the URL. \documentclass{article} \usepackage{verbatimbox,fancyvrb,url} \usepackage{amsmath} \begin{document} The table at ...

6

Verbatim environments are very special, and generally resist being the arguments of macros, which is effectively what you are doing when you try to put a verbatim environment inside another environment definition. For more details on this problem, see the UK TeX FAQ entry on the topic. Instead, what you can do is hook into the beginning of the verbatim or ...

6

Just define a new environment. The simplest way is with the verbatim package: \documentclass{article} \usepackage{verbatim} \newenvironment{inverb} {\par\addvspace{\topsep}\noindent\textbf{In verbatim}\nopagebreak \verbatim} {\endverbatim} \begin{document} Something before \begin{inverb} some text \end{inverb} Something after \end{document} With ...

6

listings provides a mathescape option to escape to LaTeX within math mode (between $...$). There are other escapable options as well, details of which are contained within the listings documentation (section 4.14 Escaping to LaTeX, p 39). Here is a quick example: \documentclass{article} \usepackage{listings}% http://ctan.org/pkg/listings \lstset{ ...

5

Geoffrey Poore develops minted further and answered in this similar tex.SE Question: This is not supported in the current release (minted 1.7). There is a \mintinline command in the development version at https://github.com/gpoore/minted. The development version is currently at 2.0-alpha2, but based on my own use and reports from others, it should be ...

5

verbatim like most LaTeX display environments is a list environment, and one of the main reasons for that is so that they do the right thing when nested in other display environment such as quote (or a similar custom environment with different indentation). \documentclass{article} \begin{document} X\dotfill X\\ X\dotfill X \begin{verbatim} %  @@@ ...

4

If you don't need any further formatting of the verbatim stuff you can use the package moreverb or fancyvrb. The provided environment verbatimtab by moreverb has an optional argument to specify the width of a tab. The package fancyvrb provides the option tabsize to speficy the width. \documentclass{article} \usepackage{verbatim,moreverb,fancyvrb} ...

4

The verbatim package has an internal interface that allows one to do this. One has to redefine \verbatim@processline, adding an \hspace command at its start: \documentclass{article} \usepackage{verbatim} \newlength\myverbindent \setlength\myverbindent{1in} % change this to change indentation \makeatletter \def\verbatim@processline{% ...

2

There is no Euro symbol in the standard fonts, so textcomp is required. However, the glyph in the European Modern fonts is ugly and wrong; with Latin Modern it's better. \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{textcomp} \begin{document} \begin{verbatim} fr_FR: 123 456,78 € de_DE: ...

2

As long as your verbatim block doesn't span a page break, you can use the verbatimbox package. The verbbox environment puts the verbatim into a box that can be recalled with \theverbbox. The [t] option makes sure the box is strutted, to give the proper vertical spacing from the previous line. \documentclass{article} \usepackage{verbatimbox} ...

1

Is this solution acceptable? \documentclass{article} \usepackage{wrapfig} \begin{document} \noindent \def \myasywidth {5cm} \begin{wrapfigure}{l}{\myasywidth} \vspace{0pt} \rule{\myasywidth}{\myasywidth} \end{wrapfigure} % % {\ttfamily\obeyspaces\obeylines settings.outformat="pdf"; [...listing ommited...] draw((x,0) -- striptop -- (x+dx,0) -- cycle, blue); ...

1

My current best effort at this is based on the concept by @Gilles at Unix SE. It is not a pure *TeX implementation, and it is not perfect, but it is the one that has allowed me to compress my first 1.4MB of text onto 36 pages: around 40kB and 1400 lines per page. I use perl to pre-process the input text to escape LaTeX special characters, and also add ...

Only top voted, non community-wiki answers of a minimum length are eligible