# Quote verbatim in Latex

I would like to quote some passages using the quote environment. However the quoted passage contains some math mode equations written in text format like "Your paper is worthless because x^2 +y^2 = 0." I would like to be able to quote this as is, without using the math-mode. Is there something like a mixture of verbatim and quote environments so that I don't have to go through every instance of such equations and replace them with something like \verb*x^2+y^2=0*? Something perhaps with some flexibility in the choice of fonts too.

EDIT: Basically, what I want is all the text-handling capabilities of LaTeX for the quoted text, while treating things like a^2+b^2 = 0 as is, just some characters to be displayed verbatim. I don't know if this is achievable without surrounding a^2+b^2=0 or the like with special characters.

• Please provide MWE! Sep 8 '15 at 10:52
• how are Greek letters \sigma... or symbols \sum, \prod supposed to be treated ?
– user4686
Sep 9 '15 at 5:55
• @jfbu, exactly as they are written \sigma, \sum, \prod. People often do this when writing emails with math symbols. Sep 10 '15 at 9:07

You can set this "verbatim quote" as a regular listing. Below I defined a new listing verbquote:

\documentclass{article}

\usepackage{listings,lipsum}

\lstnewenvironment{verbquote}[1][]
{\lstset{columns=fullflexible,
basicstyle=\ttfamily,
xleftmargin=2em,
xrightmargin=2em,
breaklines,
breakindent=0pt,
#1}}% \begin{verbquote}[..]
{}% \end{verbquote}

\begin{document}

\lipsum[1]

\begin{verbquote}
Your paper is worthless because x^2 + y^2 = 0. Please reconsider what you are attempting.
\lipsum[2]
\end{verbquote}

\lipsum[2]

\end{document}


All content within verbquote will be set as-is. You can change the font (or any other styles) using any of the options provided for listings.

You can also just reset the category codes of active keys that could cause problems to print them as "other" (category code 12):

\documentclass{article}

\usepackage{lipsum}
\usepackage[T1]{fontenc}% http://tex.stackexchange.com/q/48632/5764

\newenvironment{verbquote}
{\catcode ^=12% Math superscript
\catcode _=12% Math subscript
\catcode $=12% Math deliniation \begin{quote}} {\end{quote}} \begin{document} \lipsum[1] \begin{verbquote} Your paper is worthless because x^2 + y_2 = 0 or about$0. Please reconsider what you are attempting.
\end{verbquote}

\lipsum[2]

\end{document}

• I thought the OP wants the regular text font for text material inside a quote, and verbatim look (i.e., a monospace font) for math material.
– Mico
Sep 8 '15 at 15:11
• @Mico, The change of fonts would have been nice, but I guess there is a trade-off with the other thing I want, namely, just copy-pasting what someone wrote without going through adding dollar signs. What I meant by the choice of font was that the whole font for the quoted text need not be typewriter. This answer is closest to what I had in mind. Sep 9 '15 at 2:26
• @passerby51: You can adjust the basicstyle to suit your needs, or whichever font you want. Sep 9 '15 at 2:28
• @Werner, thanks. I have experimented with your verbqoute, and one thing I don't like about it is how it handles the usual text. LaTeX text looks much better, in terms of spacing and end of line breaks, etc. Is there any way to have that so of thing with a verbatim environment? Sep 9 '15 at 5:45
• @passerby51: I've provided an updated version of verbquote that might be useful. There are many more options, but I'm not sure what you might include in the quote. Sep 9 '15 at 6:06

You can achieve the same effect as in Mico's answer with the help of package shortvrb, to transform $ temporarily as a switch to verbatim. The quote environment is modified via etoolbox exactly as in Mico's answer. \documentclass{article} \usepackage{shortvrb} \usepackage{etoolbox} \AtBeginEnvironment{quote}{\MakeShortVerb\$}
\AtEndEnvironment{quote}{\DeleteShortVerb\$} \begin{document} \noindent$a^2 + b^2 = 0$\begin{quote} Your paper is worthless because you claim that$a^2 + b^2 = 0$and that$1 + 1 = 3$. \end{quote}$1 + 1 = 3$\thispagestyle{empty} \end{document}  • +1. I didn't know the shortvrb package until I read your answer. – Mico Sep 8 '15 at 16:48 • @jfbu, Thanks. As much as I like this answer, this will require me to go through the quoted text and surround math-mode mark-up with$...$. I wanted to avoid this. I should have made this more clear in my question. Although, your solution is still great for what it does. Sep 9 '15 at 2:21 I'm interpreting your objective as follows: (i) Inside quote environments, and only inside quote environments, inline math material -- i.e., stuff that starts and ends with a $ symbol -- should be typeset automatically using a monospaced font rather than in math mode. (ii) All text-mode material inside quote environments should be typeset using the regular text font.

If this interpretation is correct, it may be achieved by using LuaLaTeX and setting up a Lua function which (a) is active only inside quote environments and (b) replaces inline math mode with verbatim mode.

% !TEX TS-program = lualatex
\documentclass{article}

%% Lua-side code
\usepackage{luacode,luatexbase}
\begin{luacode}
do_conversion = false
function inline_math_to_verbatim ( line )
if do_conversion then
return (string.gsub(line,"%$(.-)%$","\\verb&%1&"))
end
end
-- assign this function to the "process_input_buffer" callback
inline_math_to_verbatim, "inline_math_to_verbatim" )
\end{luacode}

%% TeX-side code
\usepackage{etoolbox}

\begin{document}
\noindent
$a^2 + b^2 = 0$
\begin{quote}
Your paper is worthless because you claim that $a^2 + b^2 = 0$ and that $1 + 1 = 3$.
\end{quote}
$1 + 1 = 3$
\end{document}

• @passerby51 -- If you don't use \$` symbols to delimit math-mode material, what method do you use?
– Mico
Sep 9 '15 at 3:15
• just typset them as if they where text, like X_{ij} = 2 as is. Sep 9 '15 at 5:49
• @passerby51 -- I didn't ask you how the mathy material should be displayed ("as if [it] were text"). Instead, I asked you how TeX should be made aware that some of the material it's dealing with is mathy.
– Mico
Sep 9 '15 at 7:30
• Ideally it shouldn't be made aware, just like a simple text editor is not aware of them. They are just characters to be displayed. Sep 10 '15 at 9:08