答案1
答案2
如果您只是在寻找产生数学符号的代码:
在数学模式下:\langle
和\rangle
。对于延伸的括号:\left\langle
和\right\rangle
。
在文本模式下,您将需要textcomp
包,然后使用\textlangle
和\textrangle
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % For using \langle in text
\begin{document}
This is a working example of using \textlangle or \textrangle in text by simply
importing the textcomp package (see pre-amble). If instead you want to use it in math
mode, you could either do $\langle$ or $\rangle$ or you could use it in an equation
as such:
\begin{equation}
\langle
\end{equation}
\begin{equation}
\rangle
\end{equation}
\end{document}
答案3
这是一个高级示例lstlistings
,使用或多或少从生产版本中逐字复制的内容。
\lstdefinestyle{steden}{basicstyle=\ttfamily,
keywordstyle=\color{blue}\bfseries\ttfamily,
stringstyle=\color{yac}\ttfamily,
showstringspaces=false,
commentstyle=\color{darkgray}\sl\ttfamily,
emph={process,new,parfill,multifill,release,fetch,releaseAll,fetchAll,spawn,processDC,\#},
emphstyle={\color{blue}\bfseries},
emph={[2]ChanName,Process,RD,Trans,NFData,reduce,fold,parMapDC,reduceDC,parMapAt,map_par,map_farm,map_wp,parMap,farm,ssf,workpool,par,pseq},
emphstyle={[2]\color{blue}\bfseries},
emphstyle={[3]\color{red}\bfseries},
emph={[3]r0,rwhnf,rnf,rdeepseq,unsafePerformIO,IO,merge},
captionpos=b,
lineskip=-0.1ex,
frame=lines,
language=Haskell,
literate={+}{{$+$}}1 {/}{{$/$}}1 {*}{{$*$}}1 {=}{{$=$}}1
{`+`}{{+}}1 {`-`}{{-}}1 {`*`}{{*}}1
{>}{{$>$}}1 {<}{{$<$}}1 {\\}{{$\lambda$}}1 {\\n}{{\textbackslash
n}}2 {\\\\}{{\char`\\\char`\\}}1
{->}{{$\rightarrow$}}2 {>=}{{$\geq$}}2
{<-}{{$\in$}}2 % the list comprehension <-
{<--}{{$\leftarrow$}}2 % the monadic <-
{<=}{{$\leq$}}2 {=>}{{$\Rightarrow$}}2
{\ .\ }{{ $\circ$ }}3
{(.)}{{($\circ$)}}3
{>>}{{>>}}2 {>>=}{{>>=}}2 {/=}{{$\neq$}}2
{|}{{$\mid$}}1
%%% vector operations
{v+}{{$\overrightarrow{+}$}}1 {v-}{{$\overrightarrow{-}$}}1
{v*}{{$\overrightarrow{\cdot}$}}1
%%% number fields
{NN}{{$\N$}}1 {ZZ}{{$\Z$}}1 {QQ}{{$\Q$}}1
{xdd}{{$\delta$}}1
{xaa}{{$\alpha$}}1
%%% further hacks
{`l_p`}{{l\textsubscript{p}}}2
{`=`}{{$=$}}1
{p^k}{{p\textsuperscript{k}}}2
{`p^k`}{{p\textsuperscript{k}}}2
{`^2`}{{\textsuperscript{2}}}1
{`xsinn`}{{$\zeta_n^n$}}2
{bottom}{{$\bot$}}1
%% do not highlight "reduce" in a special case
{xreduce}{{reduce}}6
}
进一步简化使用的环境:
\lstnewenvironment{code*}
{%
\lstset{style=steden,
}} {}
\newcommand{\cd}[1]{\lstinline[style=steden,keepspaces=true,
breaklines=true,basicstyle=\ttfamily];#1;}
\newcommand{\inputcode}[1]{\lstinputlisting[style=steden,xleftmargin=0pt,
xrightmargin=0pt]{#1}}
\lstnewenvironment{code}
{%
\lstset{style=steden,
frame=none,
xleftmargin=30pt,
xrightmargin=10pt,
}} {}