This is probably a simple question, but I can't find the answer anywhere. How can I tell tex (latex specifically) not to format a piece of text? I.e. I want to keep indentation, line breaks, etc.
[Tex/LaTex] Latex equivalent of
verbatim
Related Solutions
Your strategy is basically a good one. I suggest a few changes. To eliminate the annoying \\
that you asked about, just use a \parskip
length to define skip between paragraphs. Then, the only \\
needed is when you need a linebreak within a paragraph (the only one here is in the salutation). Also, I found the leftbar
environment not as easy to read (in the tex code source) as a structure. So I replaced it with the macro structure named \embed
. Also, to save space on the output, I didn't have \embed
automatically provide extra space upon entry, as leftbar
did.
Obviously, these things are all a matter of taste. Conveying the information clearly to the reader is all that matters
\documentclass[
oneside,
openright,
titlepage,
dottedtoc,
numbers=noenddot,
headinclude,
footinclude=true,
cleardoublepage=empty,
abstractoff,
BCOR=5mm,
paper=a4,
fontsize=11pt,
ngerman,
american
]
{scrreprt}
\PassOptionsToPackage{utf8}{inputenc}
\usepackage{inputenc}
\usepackage{blindtext}
\usepackage[english]{babel}
\usepackage[pdfspacing]{classicthesis}
\usepackage{scalerel}
\usepackage{calc}
\global\newcounter{embedlevel}
\global\newlength\embedspace
\embedspace=2ex
\setcounter{embedlevel}{1}
\newcommand\embed[1]{%
\stepcounter{embedlevel}%
\stretchrel{\rule{0.2ex}{1ex}}{\hspace{1.8ex}\parbox{%
\textwidth-\value{embedlevel}\embedspace}{%
\rule{0ex}{2ex}#1\rule[-1.3ex]{0ex}{1.3ex}%
}}%
\vspace{.5ex}%
\addtocounter{embedlevel}{-1}%
}
\parskip 1.5ex
\begin{document}
\selectlanguage{ngerman} % american ngerman
% Disable paragraph indentation.
\setlength{\parindent}{0pt}
\begin{verbatim}
From: john.doe@yahoo.com
Subject: Your inquiry from 20042012
Date: Thu, 3 May 2012 11:34:54 +0200
To: Jane Doe <jane.doe@hotmail.com>
\end{verbatim}
Jane Doe wrote:
\embed{%
\embed{%
\embed{%
\embed{%
There are a couple of questions I like to ask. Please forward them if
you cannot do so.
}
I hope I can answer them after holidays.
}
I am back from holidays now and will look through your questionaire the next days.
}
Thank you, Mr. Doe - I am awaiting your answers.
}
Dear Mrs. Doe,
Nullam nisi nunc, ullamcorper vitae pulvinar eu, suscipit ut augue.
Donec risus mi. Nam aliquam consectetur mollis. Ut at sem quis dolor
faucibus fringilla. Quisque cursus vehicula odio, vitae placerat ipsum
dapibus id.
Best regards,\\
John Doe
(See attached file: Questions\_Doe.doc)
\begin{verbatim}
_______________________________________________________
Administration New York
John Doe
Mainstr. 3
11111 New York
T: (011) 212-4301
F: (011) 212-954301
M: john.doe@yahoo.com
\end{verbatim}
\embed{%
My question
I looking forward to reading the answers to my questions:
1. Is the world analog or digital?
}
digital
\embed{%
2. How long does the world exist?
}
analog since 1984, digital since 1999
\end{document}
While not exactly what the OP asks, it may suffice. First, it uses \detokenize
, not verbatim
, which means 1) that braces {}
must be balanced, 2) that the %
symbol is still interpreted as a comment, 3) that a space is inserted after all detokenized macro names, and 4) Hash marks #
are doubled in number.
Also, I just \allowbreak
between words, using the \fboxsep
of the colorbox to create the interword spaces.
EDITED to use \ttfamily
for the \mytokens
macro.
EDITED to fix line height, since the combination of a \strut
and \fboxsep
blew the allowed baselineskip budget.
Originally, I was not using interword space but allowed the \fboxsep
to suffice. But this caused margin issues, as nothing could stretch. So, upon RE-EDIT, I insert a space of 0pt minus \fboxsep
between words, which seems to allow enough compression to address the margin issues, while still leaving enough space between words (otherwise 2\fboxsep
).
I also rearranged the \grayspace
and allowbreak
, upon RE-EDIT, so that a linebreak would not occur before trailing punctuation.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\newcommand\mytokens[1]{\mytokenshelp#1 \relax\relax}
\def\mytokenshelp#1 #2\relax{\allowbreak\grayspace\tokenscolor{#1}\ifx\relax#2\else
\mytokenshelp#2\relax\fi}
\newcommand\tokenscolor[1]{\colorbox{gray!20}{\textcolor{blue}{%
\ttfamily\mystrut\smash{\detokenize{#1}}}}}
\def\mystrut{\rule[\dimexpr-\dp\strutbox+\fboxsep]{0pt}{%
\dimexpr\normalbaselineskip-2\fboxsep}}
\def\grayspace{\hspace{0pt minus \fboxsep}}
\begin{document}
Here is my leading text
\mytokens{Fie Fi Fo Fum, I smell the $#@*& blood of an \Englishman.
I will continue this text to observe the margins.
Fie Fi Fo Fum, I smell the \textbf{blood} of an Englishman.}
and my trailing text. And here is more text to find where the margin end
really should be.
Standard MATLAB formats are allowed, such as \mytokens{1.2}, \mytokens{-.2i},
\mytokens{1.}, \mytokens{-1.2e3}, \mytokens{+.2E-3j}. \mytokens{i} and
\mytokens{j} denote...
\end{document}
SUPPLEMENT
In response to a comment request, here is a version that takes the background color as an optional argument.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\newcommand\mytokens[2][gray!20]{\mytokenshelp{#1}#2 \relax\relax}
\def\mytokenshelp#1#2 #3\relax{\allowbreak\grayspace\tokenscolor[#1]{#2}\ifx\relax#3\else
\mytokenshelp{#1}#3\relax\fi}
\newcommand\tokenscolor[2][gray!20]{\colorbox{#1}{\textcolor{blue}{%
\ttfamily\mystrut\smash{\detokenize{#2}}}}}
\def\mystrut{\rule[\dimexpr-\dp\strutbox+\fboxsep]{0pt}{%
\dimexpr\normalbaselineskip-2\fboxsep}}
\def\grayspace{\hspace{0pt minus \fboxsep}}
\begin{document}
Here is my leading text
\mytokens{Fie Fi Fo Fum, I smell the $#@*& blood of an \Englishman.
I will continue this text to observe the margins.
Fie Fi Fo Fum, I smell the \textbf{blood} of an Englishman.}
and my trailing text. And here is more text to find where the margin end
really should be.
Standard MATLAB formats are allowed, such as \mytokens{1.2},
\mytokens{-.2i}, \mytokens[red!40]{1.}, \mytokens{-1.2e3},
\mytokens{+.2E-3j}. \mytokens[cyan!30]{i} and
\mytokens[green!20]{j} denote...
\end{document}
Best Answer
I think the closest thing that will do what you want is the
alltt
package:Unfortunately
alltt
doesn't contain any features to globally change the font it uses, but as you can see setting it to use roman manually works fine.