I want the following line inside a *.tex file to be printed "as is":
while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}
When I wrap it in a \verb command like this:
\verb"while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}"
it doesn't work, and I get:
! Undefined control sequence.
All other google answers are so complicated.
Surely, there's got to be an easy way to do this, right? Thanks!
EDIT:
Here is the minimal counter example requested in the comments:
%%%%%%%%%%%%%%%%%%%%%%%%%%
% document class: beamer %
%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{beamer}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% no navigation bars please %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}[frame number]{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% no navigation symbols please %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{navigation symbols}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% no footers at all please %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% center the title please %
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{frametitle}[default][center]
%%%%%%%%%%%%%%%%%%
% begin document %
%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%
% title %
%%%%%%%%%
\title{Some Title}
%%%%%%%%%%
% author %
%%%%%%%%%%
\author{Some Author}
%%%%%%%%%%%%
% date ... %
%%%%%%%%%%%%
\date{\today}
%%%%%%%%%%%%%
% frame ... %
%%%%%%%%%%%%%
\frame{\titlepage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SECTION :: Introduction %
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Section Introduction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Frame Title :: Introduction %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame{\frametitle{Status}
%%%%%%%%%%%%%%%%%%
% Items :: Begin %
%%%%%%%%%%%%%%%%%%
\begin{itemize}
\item
while (tmp[0] == 'A' $||$ tmp[1] == 'B') $\{$tmp++;$\}$
\end{itemize}
}
\end{document}
To print an actual backslash in LaTeX you use the command \backslash
, so for your code:
while (tmp[0] == '\backslash r' || tmp[0] == '\backslash n') {tmp++;}
EDIT: I forgot you need this command in math mode. If you want everything "as is", this is the code you need (for the vertical lines and the curly brackets as well):
while (tmp[0] == `$\backslash$r' $\|$ tmp[0] == `$\backslash$n') $\{$tmp++;$\}$