3
votes
2answers
119 views

create macro to verbatim output of command [closed]

The code \newcommand{\dosomething}[1]{#1 #1} \expandafter\verb\expandafter+\dosomething{blub}+ produces the verbatim-output blub blub. Now I want to create a macro \myverb for the second line, ...
3
votes
1answer
77 views

define a newcommand that will put text in verbatim

For making a report of my work, I am facing a problem of writing varbatim too frequently. So, I need a workout. Say, I define a newcommand as (for example) \newcommand{\uve}{\textbf{In verbatim}} ...
7
votes
1answer
64 views

Modifying alltt

I want to create an environment which wraps alltt in such a way that the character ' is replaced by \textquotesingle wherever it occurs inside the environment but is as normal elsewhere. I have tried ...
9
votes
2answers
229 views

How can I encode the current document as a QR code with pst-barcode?

\documentclass{article} \usepackage{pst-barcode} \begin{document} \begin{pspicture} \psbarcode{\input{\jobname.tex}}{}{qrcode} \end{pspicture} \end{document} I tried placing \expandafters before ...
3
votes
1answer
161 views

Hyphenation when using \verb command

I'm having a problem using \verb command. Usually when I want some verbatim font in the current line (not in a new paragraph) I use the \verb command, not the verbatim environment. So, when I use ...
9
votes
2answers
165 views

Print small TeX code verbatim and render it

To write some documentation, I would like the ability to define a command such as \showcase{x^{y}\in\Omega} which expands to something roughly equivalent to \verb|x^{y}\in\Omega| & ...
7
votes
1answer
107 views

Incorporate asymptote environment into macro

I'm trying to write a macro (ideally an environment, but a command would do) that takes a piece of Asymptote code, displays it in a verbatim environment, and then runs it through an asy environment. ...
10
votes
2answers
138 views

Preserving (and Controlling) Expandedness

In most cases, by the time output gets to your screen, arguments are fully expanded and my question is moot. But sometimes (verbatim being a common example), one wishes to operate on arguments with ...
7
votes
1answer
100 views

Purpose of \do@noligs in LaTeX verbatim environment

I'm trying to figure out how the verbatim environment works. In the basic LaTeX file latex.ltx I find the following definition (line 4037): ...
4
votes
4answers
683 views

Defining a new environment extending a verbatim environment

Why is it not possible to define a new environment that extends a verbatim environment? Consider, e.g.: \documentclass{article} \newenvironment{myverbatim}{\tiny\begin{verbatim}}{\end{verbatim}} ...
6
votes
2answers
209 views

Custom verbatim that sets all spaces (“ ”) as visible spaces (“␣”) that can line-break

It makes sense to typeset code in a monospaced font. Sometimes such code needs to be embedded in a paragraph context, and then it will be useful to allow it to linebreak. In order to visualize spaces ...
1
vote
1answer
75 views

Using verbatim in a definition [duplicate]

I actually need to store some verbatim text in a definition so I can reuse it several times. Here is a very short snippet: % here I store verbatim text \def\foo{ bar \verb'baz' spam } % now I ...
3
votes
1answer
280 views

How can I create wrapper macro for lstinline?

Using \lstinline I can include inline code snippets in a paragraph. I would like to provide a macro that selects formatting, etc, for lstinline so I can just do, say, \codeinline{snippet}. I had ...
2
votes
2answers
33 views

verbatim within… a package delivers a string from a file and that string needs to be printed without interpretation

The csvtools package warns in its documentation from interpretable inputs but offers no solution as far as I can see. This Code generates a table \documentclass{article} \usepackage{csvtools} ...
7
votes
1answer
169 views

Generating code examples

I would like to make a table showing some custom commands that I have defined. It would be nice if I could do something like the following. \documentclass{article} ...
4
votes
1answer
583 views

lstlisting in a newenvironment

I have a problem with the lstlisting package. I want to define an \newenvironment with one obligatory parameter, which will be the caption name for the lstlisting. I will also have other lstlisting ...
4
votes
2answers
908 views

newcommand for verbatim

I'm trying to write a \newcommand for verbatim: \newcommand{\codeline}[1]{\begin{verbatim}{#1}\end{verbatim}} and use it as \codeline{int foo;} but it gives an error "File ended while scanning ...
5
votes
1answer
493 views

Alias for verbatim environment

I'm trying to create an alias for the verbatim environment like this: \newcommand{\vb}[1]{\begin{verbatim} #1 \end{verbatim}} So I can use it like this: \vb{ word. } But when using it, I ...
2
votes
2answers
453 views

Making more easy the itemized of item with tabulation system

Actually, isn’t not really a question. (Since my examinations get close, I don't really have the time to search for a solution to my problems.) Rather than using the common \item, I'd like to use ...
7
votes
1answer
215 views

Typeset text as written (similar to verbatim) within a custom command?

I'm trying to define a new command that puts text in a coloured background, reproduces it exactly how it's defined in the .tex file (in a similar way to verbatim), and won't force me to use ...
4
votes
2answers
417 views

Define my own short-verb like macro?

I'm trying to define shorthand macros for \texttt that are a bit like the \verb ones. The end result is to do +asdf+ and this have the same effect as \texttt{asdf}. This is like the DefineShortVerb ...
3
votes
1answer
88 views

Create command that displays input exactly

I want to create a command whose argument is used within a \label{} command. I also want a boolean switch that turns on/off the display of this label for editing purposes. Here is pseudo-code for what ...
13
votes
1answer
5k views

How do you insert an inline verbatim?

I'm trying to add an inline verbatim into a \paragraph? Was wondering how do you do that?
3
votes
2answers
540 views

\verb in custom command

I have \newcommand\dd[2]{\item[\texttt{#1}] #2} and later I have \dd{bc}{text \verb#$(echo 5+4 | bc)# text \verb#$((5+4))# text} and I get ! You can't use `macro parameter character #' in math ...
6
votes
2answers
135 views

How can I show a macro as text?

Say I want to make a file which has as text \documentclass{article} I found out I can do it like this: \documentclass{article} \begin{document} \begin{verbatim} \documentclass{article} ...
2
votes
1answer
339 views

Potential problems from passing macro arguments to \verb

I've been working on a command that will typeset snippets of code within a paragraph. I'm aware of listings and company, but I want something that will just typeset the code verbatim and also allow ...
5
votes
4answers
1k views

Wrapping code (listings, verbatim, or other method) inside a newcommand

For some teaching I've been doing, I'd like to have code from two different languages side-by-side. To do so, I hacked together a newcommand which uses a tabular environment to arrange two verb ...
4
votes
2answers
143 views

Problem putting answers in a macro

I want to put the \begin{sol} and \end{sol} from the answers package in a macro like \newcommand{\assignment}[2] { \item #1 \begin{sol} #2 \end{sol} } ### \assignment{question}{answer} It's just ...
2
votes
1answer
590 views

Verbatim text can't be shown correctly in pdf

I try to change the font of verbatim text as below % Used by @verbatim ... @endverbatim \newenvironment{DoxyVerb}{% \verbatim% \fontencoding{OT1}\fontfamily{ptm}\fontseries{m}\fontshape{n}% ...
6
votes
3answers
611 views

How can I redefine the \verb|…| command?

I'd like to redefine the \verb|...| command so that it had a light-gray background and a little bit darker border around it, and a little bit of padding to make this background "box" noticable. Anyone ...
3
votes
1answer
349 views

How to treat the arguments of a macro as literal or verbatim text?

I'm working on a package that allows Python code to be entered within certain commands and environments, saves the Python code to external files and executes it, and brings back the results via ...
2
votes
3answers
2k views

Any ideas why this \newcommand{\n}{\lstinline|\n|} macro doesn't work?

So I created a new macro \newcommand{\n}{\lstinline|\n|} but for some reason when I use it, all I get is bold 'n' letter and not a nice \n. Any ideas?
6
votes
2answers
338 views

In the verbatim environment, how can I display an 'if' statement I declared as '\ifcondition'?

I have declared a couple of if commands of the form \newif\iffinal \newif\ifsolutions Now I want to write about it in the same document! So I want to write something like \iffinal (...) ...
4
votes
1answer
288 views

Printing verbatim command inputs in commands

I want to define a command \mydef that does something like this: \mydef{\foo{bar}} produces \def\foo{bar} \verb|\foo=bar| The command: \newcommand{\mydef}[1]{\def #1} does the first bit, but ...
2
votes
2answers
609 views

ignorespace and unskip in verbatim/listings?

I am writing a \bashDemo macro that will (a) execute its argument in a shell, e.g., bash, script, and (b) display the argument in a listings. So, \bashDemo ls -ls > myfiles \END will both run ls ...
0
votes
2answers
645 views

Combination of \verb and \texttt

Also I read: When should one use \verb!! and when \texttt{} My issue at hand is that I would like to write a little more than just "small pieces" (wording in linked question) of program code, but ...
11
votes
1answer
1k views

Alternatives to $\backslash$

Background Instead of marking up the text with bold or emphasis, I read (and agree) that it is better to define a command, or environment, that describes the content. Then apply text formatting ...
3
votes
1answer
319 views

Verbatim inside def in eplain

How can I use \verbatim inside my own \def with eplain? The eplain reference suggests to change catcodes to accomplish this, but doesn't provide an example of this. Crarification: I would like to ...