Tag Info

Hot answers tagged

21

You start from the assumption that the syntax of \verb is inconsistent, but this is not true: \verb<char><material><char> where <char> is pretty much any character not appearing in the <material> to be typeset verbatim. Not really any, but quite; for instance * is not allowed unless one uses the \verb* variant. So \verb**foo* ...


18

In all languages the syntax of the command that breaks out of the normal syntax is different. If the syntax was \verb{...} you would not be able to have an argument of }{ Compare the CDATA construct in XML and (sometimes) HTML which has use very close to verb and very different from normal element syntax. <![CDATA[ < * <bad xml ]]> \verb is ...


5

If your verbatim doesn't use backslashes and braces, you can do it with fancyvrb: \documentclass{article}% \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{fancyvrb} \pagestyle{empty} \begin{document} \def\np{15} \begin{Verbatim}[commandchars=\\\{\}] np=\np #THIS IS WHAT I WANT TO GET, WHEN PRINTED, IT SHOULD BE np=15 p1=0 ...


5

Please read section "2.3 Special characters" of the documentation for package qrcode. \qrcode reads the argument verbatim except for characters \, {, and } to allow macro expansion. These characters and the other special characters including spaces needs an "escaping" with the backslash, because their catcodes are already assigned at the time of the macro ...


4

Just use \verb|tran.prob(N=5, q=0.5)|. \documentclass{article} \begin{document} We call the function below via \verb|tran.prob(N=5, q=0.5)|, which is inline. \end{document}


3

You can use the listings package; here's a little example: \documentclass{article} \usepackage{listings} \usepackage{xcolor} \definecolor{maincs}{RGB}{177,0,39} \definecolor{secondarycs}{RGB}{255,179,246} \definecolor{tertiarycs}{RGB}{0,149,86} \lstset{ language=[LaTeX]TeX, basicstyle=\ttfamily\small, columns=fullflexible, breaklines=true, ...


3

The fleqn option causes displayed math expressions to be placed at a fixed indent from the left margin; this fixed indent is controlled by \mathindent, so you need a verbatim environment with this same indentation from the left margin. Below I show two options. Using the fancyvrb package all you have to do is to set \fvset{xleftmargin=\mathindent} A ...


2

This shows only a small amount of the tcolorbox and listings features: \documentclass{article} \usepackage[most]{tcolorbox} \begin{document} \begin{tcblisting}{listing options={numbers=left},colback=green,arc=0mm,auto outer arc} Some Code with math output: \[ E = mc^2 \] \end{tcblisting} % And now listing only ...


2

\documentclass[11pt,fleqn]{article} \usepackage{amsmath} \newenvironment{mindent} {\list{}{\rightmargin0pt \leftmargin\mathindent}% \item\relax} {\endlist} \begin{document} Lorem ipsum \begin{equation*} e^{iπ}=-1 \end{equation*} \begin{mindent} \begin{verbatim} \\ Can I have margin ? \end{verbatim} ...


2

\documentclass[11pt,fleqn]{article} \usepackage{amsmath,verbatim,showframe} \newenvironment{myverbatim}% {\par\hspace*{\dimexpr-\parindent+\mathindent\relax}% \minipage{\dimexpr\linewidth-\mathindent\relax}\verbatim}% {\endverbatim\endminipage} \begin{document} Lorem ipsum \begin{equation*} e^{iπ}=-1 \end{equation*} \begin{myverbatim} \\ Can I have ...



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