Latex打印单斜线、反斜线r、反斜线n
Latex printing single slash, backslash r, backslash n
我想打印 *.tex 文件中的以下行 "as is":
while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}
当我将它包装在这样的 \verb 命令中时:
\verb"while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}"
它不起作用,我得到:
! Undefined control sequence.
所有其他 google 答案 所以 复杂。
当然,一定有一个简单的方法来做到这一点,对吧?
谢谢!
编辑:
这是评论中要求的最小计数器示例:
%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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}
要在 LaTeX 中打印实际的反斜杠,您可以使用命令 \backslash
,因此对于您的代码:
while (tmp[0] == '\backslash r' || tmp[0] == '\backslash n') {tmp++;}
编辑: 我忘了你在数学模式下需要这个命令。如果你想要一切 "as is",这就是你需要的代码(对于垂直线和花括号也是如此):
while (tmp[0] == `$\backslash$r' $\|$ tmp[0] == `$\backslash$n') $\{$tmp++;$\}$
我想打印 *.tex 文件中的以下行 "as is":
while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}
当我将它包装在这样的 \verb 命令中时:
\verb"while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}"
它不起作用,我得到:
! Undefined control sequence.
所有其他 google 答案 所以 复杂。
当然,一定有一个简单的方法来做到这一点,对吧? 谢谢!
编辑:
这是评论中要求的最小计数器示例:
%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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}
要在 LaTeX 中打印实际的反斜杠,您可以使用命令 \backslash
,因此对于您的代码:
while (tmp[0] == '\backslash r' || tmp[0] == '\backslash n') {tmp++;}
编辑: 我忘了你在数学模式下需要这个命令。如果你想要一切 "as is",这就是你需要的代码(对于垂直线和花括号也是如此):
while (tmp[0] == `$\backslash$r' $\|$ tmp[0] == `$\backslash$n') $\{$tmp++;$\}$