Hot answers tagged

5

You can use fancyvrb that respects TAB characters by default and allows to set the number of spaces they mean at runtime. \documentclass{article} \usepackage{showframe} % just for the example \usepackage{fancyvrb} \begin{document} First attempt \begin{verbatim} ##### ######### ############# \end{verbatim} Second attempt: \begin{Verbatim}...


4

Use this: \usepackage{fancyvrb} \newcommand\Cpp{C\Verb!++!} But why not a simple C{}\texttt{++}?


3

Try this. Here, I use the accsupp package that allows, when creating the PDF, different things to be placed on the paper versus in the PDF "internal" document (used for copy/paste). The nice feature is that the text placed in the internal document from an AccSupp call is a single entity to the PDF and cannot be copy/pasted in part, but only in whole. ...


3

You can't have \verb inside the argument to another command (including \newcommand). The newverbs package provides “quoted verbatim” out of the box and also features \newverbcommand to do many more things. \documentclass{article} \usepackage{newverbs} \begin{document} \qverb|test\*&}| \end{document}


3

A quick solution based on the package documentation for algorithm2e \documentclass{standalone} \usepackage{algorithm2e} \begin{document} \begin{algorithm}[H] \SetStartEndCondition{ }{}{}% \SetKwProg{Fn}{def}{\string:}{} \SetKwIF{If}{ElseIf}{Else}{if}{:}{elif}{else:}{}% \SetKwFunction{FnFoo}{foo} \DontPrintSemicolon \SetAlgoLined \Fn{\FnFoo{}}...


2

Turns out the moreverb package is just for this kind of situation: \usepackage{moreverb} ... \begin{verbatimtab} ... \end{verbatimtab} From the documentation: \begin{verbatimtab}[⟨tab width⟩] reproduces its body verbatim, with the tabs expanded to the given width (the default value is 8).


2

Uses my answer at pseudo code with vertical line, modified to make rules gray in color. \documentclass{article} \usepackage{xcolor} \def\lindent{.5ex} \def\rindent{2ex} \def\rthk{1.5pt} \newcommand\block[3]{\unskip% \noindent\parbox[b]{\textwidth}{\strut\ignorespaces#1\strut}\\ \setbox0=\hbox{\parbox[b]{\textwidth}{\strut\ignorespaces#2\strut}}% \...


1

If you want to completely remove the leading, you need to set \baselineskip to a very large negative dimension, so between every pair of lines \lineskip glue will be inserted; set this to zero and you're done. \documentclass{article} \usepackage{fontspec,fancyvrb} \setmonofont{DejaVu Sans Mono} \DefineVerbatimEnvironment{VRB}{Verbatim}{% formatcom={\...


1

I believe you want something like this: \usepackage{fancyvrb} \newenvironment{jeditoutput} { \VerbatimEnvironment \begin{Verbatim}% } { \end{Verbatim}% } The \VerbatimEnvironment tells fancyvrb to look for \end{jeditoutput} as the end of the environment, rather than \end{Verbatim}. Then you can proceed to use the normal fancyvrb environment. The % ...


1

I'm afraid your assertion that the whitespace to the left of the hash symbols is "removed, or normalized somehow" in a verbatim environment is incorrect, as the following example shows. (The framelines in the screenshot serve to denote the edges of the text block.) \documentclass{article} \usepackage{showframe} \begin{document} \noindent \begin{verbatim} ...


1

tcolorbox can also draw boxes around verbatim text \documentclass{article} \usepackage{tcolorbox} \begin{document} This is text. \begin{tcolorbox} This is text. \begin{verbatim} This is some more text. This is a second line #/& \end{verbatim} And this is even more text. \end{tcolorbox} And this is even more text. \end{document}



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