问题描述
我希望* .tex文件中的以下行按原样"打印:
I want the following line inside a *.tex file to be printed "as is":
while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}
当我将其包装在\ verb命令中时,如下所示:
When I wrap it in a \verb command like this:
\verb"while (tmp[0] == '\r' || tmp[0] == '\n') {tmp++;}"
它不起作用,我得到:
! Undefined control sequence.
所有其他Google答案都很复杂.
All other google answers are so complicated.
当然,必须有一种简单的方法,对吗?谢谢!
Surely, there's got to be an easy way to do this, right?Thanks!
这是评论中要求的最小计数器示例:
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}
推荐答案
要在LaTeX中打印实际的反斜杠,请使用命令\backslash
,因此对于您的代码:
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++;}
编辑:我忘了您在数学模式下需要此命令.如果您希望一切都保持原样,这就是您需要的代码(垂直线和大括号也是如此):
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++;$\}$
这篇关于乳胶印刷单斜杠,反斜杠r,反斜杠n的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!