我有一些算法,我想在打字机模式下设置变量。因此我使用 \mathtt。但我的印象是 >>大于或等于<< 这样的符号看起来太大了。
也许我的印象是错误的。但我原本以为它会小一点。这是我的 MWE:
\documentclass{article}
\usepackage[german, linesnumbered, boxruled]{algorithm2e}
\usepackage{algorithmic}
\newcommand{\pythonsyntax}{
\SetStartEndCondition{ }{}{}%
\SetKwProg{Fn}{Funktion}{:}{End}
\SetKwFunction{Range}{range}%%
\SetKw{KwTo}{in}\SetKwFor{For}{for}{\string:}{}%
\SetKwIF{If}{ElseIf}{Else}{if}{:}{elif}{else:}{endif}%
\SetKwFor{While}{while}{:}{endwhile}%
\SetKwFor{For}{for}{:}{endfor}
\SetKw{or}{or}
\newcommand{\forcond}{$i$ \KwTo\Range{$n$}}
\AlgoDontDisplayBlockMarkers
\SetKw{in}{in}
}
\newcommand{\basic}{
\DontPrintSemicolon
\SetAlgoLined
\SetKwInput{algoinput}{Eingabe}
\SetKwInput{algooutput}{Ausgabe}
\SetKw{return}{return}
\SetKw{and}{and}
\SetKw{continue}{continue}
\SetKw{in}{in}
\SetKw{to}{to}
\newcommand{\algotrue}{\return\texttt{True}}
\newcommand{\algofalse}{\return\texttt{False}}
}
\newcommand{\eingabe}[1]{\algoinput{#1}}
\newcommand{\ausgabe}[1]{\algooutput{#1}}
\newcommand{\funktion}[2]{\Fn{#1}{#2}}
\begin{document}
\begin{algorithm}[H]
\caption{This is an MWE} \label{algo: findjacobikandidat}
\basic
\pythonsyntax
\eingabe{Some variables \texttt{a} and \texttt{b}}
\ausgabe{Some other variables}
\funktion{$\mathtt{function(h, k, p)}$}{
\If{$\mathtt{k \geq 3}$}{\texttt{World ends}}
}
\end{algorithm}
\end{document}