如何使用 `minted` 宏包的 `beameroverlays` 选项?

2020-05-11 23:41发布

## 检查 -已在issues中进行搜索 ## 编译环境 -操作系统 Windows 10 -Tex发行版 TeXLive2020 我的需求是使用 `minted` 宏包在 `beame...

## 检查 -已在issues中进行搜索 ## 编译环境 -操作系统 Windows 10 -Tex发行版 TeXLive2020 我的需求是使用 `minted` 宏包在 `beamer` 文档类中实现 `texdoc beamer` 中第 27 页的中部的 > On second thought, Euclid would prefer to uncover part of the algorithm stepwise and to add an emphasis on certain lines or parts of lines. He can use package like alltt for this, but in simple cases the environment{semiverbatim} defined by beamer is more useful: It works like {verbatim}, except that , {, and } retain their meaning (one can typeset them by using \\, {, and }) 通过 ![minted的issue](https://github.com/gpoore/minted/issues/155) 可以产生如下可实现的代码: ```latex \documentclass{beamer} \usepackage{minted} \begin{document} \begin{frame}[fragile] \begin{minted}[escapeinside=||, beameroverlays]{text} |\uncover<1>{\alert<0>{int main (void)}}| |\uncover<1>{\alert<0>{\{}}| |\uncover<1>{\alert<1>{ \alert<4>{std::}vector is\_prime (100, true);}}| |\uncover<1>{\alert<1>{ for (int i = 2; i < 100>{\alert<2>{ if (is\_prime[i])}}| |\uncover<2>{\alert<0>{ \{}}| |\uncover<3>{\alert<3>{ \alert<4>{std::}cout << i>{\alert<3>{ for (int j = i; j < 100>{\alert<3>{ is\_prime [j] = false, j+=i);}}| |\uncover<2>{\alert<0>{ \}}}| |\uncover<1>{\alert<0>{ return 0;}}| |\uncover<1>{\alert<0>{\}}}| \end{minted} \end{frame} \end{document} ``` 但是仍有未解决的问题: 1. 被 `||` 包围的 `{}` 和 `_` 会被 LaTeX 解析, 想正常输入的话使用了`\{ \} \_`, 但是如此输出得到的 `{}_` 不是等宽字体, 是否有解决方法? 图片放在下面 2. 如果将 `minted` 的语言设置为 `c` 可以编译通过但是会出现预期之外的效果, 图片放在下面: ![{}_的图](https://i.loli.net/2020/05/11/243tgVF6L1xBObR.png) ![将语言变为c](https://i.loli.net/2020/05/11/o3nuvJVL1cSDglN.png)
1条回答

问题中提到的 issue 网址为: https://github.com/gpoore/minted/issues/155


在群中交流得到了以下的结果

6RW[2B}[VZS~)O$95V@L_HR.png

image.png

image.png

一周热门 更多>