Latex 列表 - 大写关键字的包格式选项
我使用列表包来插入源代码。我想在输出中打印所有大写的关键字,无论输入中的大小写如何。
手册上说它
keywordstyle=[number][*]style
生产的正是我想要的。然而,以下(几乎)最小的示例不起作用。 如果我将keywordstyle设置为“[1][]{\bfseries}”,我最终会在每个关键字前面加上“[]” 和“[*]{\bfseries}”在文档的开头给了我一个星号。
我还尝试了“\MakeUppercase”和“{\MakeUppercase}”作为关键字样式,这导致了几个错误,第一个是:
! Incomplete \iffalse; all text was ignored after line 11
最小示例:
\documentclass{article}
\usepackage{listings}
\lstdefinelanguage{KA_assembler}
{morekeywords={add,and,or,xor},
keywordstyle=[1][*]{\bfseries},
sensitive=false,
}
\lstset{language=KA_assembler}
\begin{document}
\begin{lstlisting}
and %r1, %r2
xor %r2, %r3
and %r4, %r5
\end{lstlisting}
\end{document}
我使用 Miktex 来编译 tex 文件。那么如何强制关键字大写呢?
I use the listings package to insert source code. I would like to print all keywords uppercase in the output, regardless of the case in the input.
The manual states that
keywordstyle=[number][*]style
produces just what I want. However the following (almost) minimal example does not work.
if I set keywordstyle to "[1][]{\bfseries}" I end up with "[]" in front of every keyword
and "[*]{\bfseries}" gives me an asterisk in the start of the document.
I also tried "\MakeUppercase" and "{\MakeUppercase}" for keywordstyle which resulted in several errors, the first being:
! Incomplete \iffalse; all text was ignored after line 11
Minimal example:
\documentclass{article}
\usepackage{listings}
\lstdefinelanguage{KA_assembler}
{morekeywords={add,and,or,xor},
keywordstyle=[1][*]{\bfseries},
sensitive=false,
}
\lstset{language=KA_assembler}
\begin{document}
\begin{lstlisting}
and %r1, %r2
xor %r2, %r3
and %r4, %r5
\end{lstlisting}
\end{document}
I use Miktex for compilation of the tex files. So how do I force uppercase for Keywords?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在手册中,* 周围的括号看起来与
number
周围的括号有点不同。原因是 * 周围的括号并不意味着在乳胶代码中使用,它们只是表明 * 的存在是可选的。所以尝试或者
-它对我有用。
In the manual, the brackets around the * look a bit different then the brackets around
number
. The reason is that the brackets around * are not meant to be used in the latex code, they just indicate that the presence of the * is optional. So tryor
- it worked for me.