以下beamer
文件按照该序列编译成功
pdflatex -shell-escape file
pythontex file
pdflatex -shell-escape file
file.tex
:
\documentclass{beamer}
\usepackage{pythontex}
\begin{document}
\begin{frame}
\py{2}
\pyv{a}
\end{frame}
\end{document}
生产
(如果想要更丰富多彩的内容,请替换\pyv{a}
为\pyv{float}
例如
beamer
但是,用以下方式替换类beamerswitch
即可
\documentclass{beamerswitch}
\usepackage{pythontex}
\begin{document}
\begin{frame}
\py{2}
\pyv{a}
\end{frame}
\end{document}
无法呈现\pyv
输出
我非常确定这种形式的代码在 1 年前对我来说是有效的。在评论中,已确认 texlive 2019 设置可以使用。
pythontex
任何与 相关的问题都存在。通过调用来pygments
使用prettyprinterfancyvrb
\usepackage[prettyprinter=fancyvrb]{pythontex}
在两种情况下均给出正确的输出。
任何修复版本的方法pygments
都将受到赞赏,因为beamerswitch
这对我的目的非常有用。
指出问题所在的想法,以及报告哪些系统可以工作或不工作,也会有所帮助。目前我不清楚哪个组件有问题,所以我可以在哪里报告错误/问题。
文件版本
LaTeX2e <2020-10-01> patch level 4
我在 texlive 2020 和 Mac 下运行。
\listfiles
生成下面的长文件版本列表。
降级beamerswitch
到版本1.6.1
没有帮助。
降级pythontex
到版本0.16
也无济于事。
从评论来看,该代码在 texlive 2019 设置中有效。
*File List*
beamerswitch.cls 2020/06/06 v1.7 Convenient mode selection in Beamer documents
xkeyval.sty 2020/11/20 v2.8 package option processing (HA)
xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
xkvltxp.sty 2014/05/25 v1.3 LaTeX2e kernel patch (HA)
etoolbox.sty 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
xstring.sty 2019/02/06 v1.83 String manipulations (CT)
shellesc.sty 2019/11/08 v1.0c unified shell escape interface for LaTeX
iftex.sty 2020/03/06 v1.0d TeX engine tests
beamer.cls 2020/11/26 v3.60 A class for typesetting presentations
beamerbasemodes.sty
beamerbasedecode.sty
ifpdf.sty 2019/10/25 v3.4 ifpdf legacy package. Use iftex instead.
beamerbaseoptions.sty
geometry.sty 2020/01/02 v5.9 Page Geometry
ifvtex.sty 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
size11.clo 2020/04/10 v1.4m Standard LaTeX file (size option)
pgfcore.sty 2020/12/27 v3.1.8b (3.1.8b)
graphicx.sty 2020/09/09 v1.2b Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)
trig.sty 2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg 2016/06/04 v1.11 sample graphics configuration
pdftex.def 2020/10/05 v1.2a Graphics/color driver for pdftex
pgfsys.sty 2020/12/27 v3.1.8b (3.1.8b)
pgfrcs.sty 2020/12/27 v3.1.8b (3.1.8b)
pgfrcs.code.tex
pgfsys.code.tex
pgfsyssoftpath.code.tex 2020/12/27 v3.1.8b (3.1.8b)
pgfsysprotocol.code.tex 2020/12/27 v3.1.8b (3.1.8b)
xcolor.sty 2016/05/11 v2.12 LaTeX color extensions (UK)
color.cfg 2016/01/02 v1.6 sample color configuration
pgfcore.code.tex
xxcolor.sty 2003/10/24 ver 0.1
atbegshi-ltx.sty 2020/08/17 v1.0a Emulation of the original atbegshi package
with kernel methods
hyperref.sty 2020-05-15 v7.00e Hypertext links for LaTeX
ltxcmds.sty 2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
pdftexcmds.sty 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO)
infwarerr.sty 2019/12/03 v1.5 Providing info/warning/error messages (HO)
kvsetkeys.sty 2019/12/15 v1.18 Key value parser (HO)
kvdefinekeys.sty 2019-12-19 v1.6 Define keys (HO)
pdfescape.sty 2019/12/09 v1.15 Implements pdfTeX's escape features (HO)
hycolor.sty 2020-01-27 v1.10 Color options for hyperref/bookmark (HO)
letltxmacro.sty 2019/12/03 v1.6 Let assignment for LaTeX macros (HO)
auxhook.sty 2019-12-17 v1.6 Hooks for auxiliary files (HO)
kvoptions.sty 2020-10-07 v3.14 Key value format for package options (HO)
pd1enc.def 2020-05-15 v7.00e Hyperref: PDFDocEncoding definition (HO)
intcalc.sty 2019/12/15 v1.3 Expandable calculations with integers (HO)
etexcmds.sty 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
url.sty 2013/09/16 ver 3.4 Verb mode for urls, etc.
bitset.sty 2019/12/09 v1.3 Handle bit-vector datatype (HO)
bigintcalc.sty 2019/12/15 v1.5 Expandable calculations on big integers (HO)
hpdftex.def 2020-05-15 v7.00e Hyperref driver for pdfTeX
atveryend-ltx.sty 2020/08/19 v1.0a Emulation of the original atvery package
with kernel methods
rerunfilecheck.sty 2019/12/05 v1.9 Rerun checks for auxiliary files (HO)
uniquecounter.sty 2019/12/15 v1.4 Provide unlimited unique counter (HO)
beamerbaserequires.sty
beamerbasecompatibility.sty
beamerbasefont.sty
amssymb.sty 2013/01/14 v3.01 AMS font symbols
amsfonts.sty 2013/01/14 v3.01 Basic AMSFonts support
sansmathaccent.sty 2020/01/31
scrlfile.sty 2020/09/21 v3.32 KOMA-Script package (file load hooks)
scrlfile-hook.sty 2020/09/21 v3.32 KOMA-Script package (using LaTeX hooks)
scrlogo.sty 2020/09/21 v3.32 KOMA-Script package (logo)
beamerbasetranslator.sty
translator.sty 2020-08-03 v1.12c Easy translation of strings in LaTeX
beamerbasemisc.sty
beamerbasetwoscreens.sty
beamerbaseoverlay.sty
beamerbasetitle.sty
beamerbasesection.sty
beamerbaseframe.sty
beamerbaseverbatim.sty
beamerbaseframesize.sty
beamerbaseframecomponents.sty
beamerbasecolor.sty
beamerbasenotes.sty
beamerbasetoc.sty
beamerbasetemplates.sty
beamerbaseauxtemplates.sty
beamerbaseboxes.sty
beamerbaselocalstructure.sty
enumerate.sty 2015/07/23 v3.00 enumerate extensions (DPC)
beamerbasenavigation.sty
beamerbasetheorems.sty
amsmath.sty 2020/09/23 v2.17i AMS math features
amstext.sty 2000/06/29 v2.01 AMS text
amsgen.sty 1999/11/30 v2.0 generic functions
amsbsy.sty 1999/11/29 v1.2d Bold Symbols
amsopn.sty 2016/03/08 v2.02 operator names
amsthm.sty 2020/05/29 v2.20.6
beamerbasethemes.sty
beamerthemedefault.sty
beamerfontthemedefault.sty
beamercolorthemedefault.sty
beamerinnerthemedefault.sty
beamerouterthemedefault.sty
xparse.sty 2020-10-27 L3 Experimental document command parser
expl3.sty 2021-01-09 L3 programming layer (loader)
l3backend-pdftex.def 2020-01-29 L3 backend support: PDF output (pdfTeX)
pythontex.sty 2019/09/22 v0.17 execute and typeset Python code and other languages
fvextra.sty 2019/02/04 v1.4 fvextra - extensions and patches for fancyvrb
ifthen.sty 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
fancyvrb.sty 2021/01/20 v3.7 verbatim text (tvz,hv)
upquote.sty 2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbatim
lineno.sty 2005/11/02 line numbers on paragraphs v4.41
pgfopts.sty 2014/07/10 v2.1a LaTeX package options with pgfkeys
pgfkeys.sty
pgfkeys.code.tex
newfloat.sty 2019/09/02 v1.1l Defining new floating environments (AR)
currfile.sty 2020/09/29 v0.7d Provides the file path elements of the current input file
filehook.sty 2020/09/29 v0.8a Hooks for input files
filehook-2020.sty 2020/09/29 v0.8a Hooks for input files
supp-pdf.mkii
epstopdf-base.sty 2020-01-24 v2.11 Base part for package epstopdf
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
nameref.sty 2019/09/16 v2.46 Cross-referencing by name of section
refcount.sty 2019/12/15 v3.6 Data extraction from label references (HO)
gettitlestring.sty 2019/12/15 v1.6 Cleanup title references (HO)
file.out
file.out
translator-basic-dictionary-English.dict
translator-bibliography-dictionary-English.dict
translator-environment-dictionary-English.dict
translator-months-dictionary-English.dict
translator-numbers-dictionary-English.dict
translator-theorem-dictionary-English.dict
pythontex-files-file/file.pytxmcr
***********
答案1
问题出在beamerswitch
包含beamer
选项ignorenonframetext
。这会破坏pygments
包含在\AfterEndPreamble
钩子中的支持。解决方法/修复方法是
\makeatletter\mode<presentation>\beamer@ignorenonframefalse\makeatother
加载 documentclass 后beamerswitch
。因此,一个有效的示例文件变为
\documentclass{beamerswitch}
\makeatletter\mode<presentation>\beamer@ignorenonframefalse\makeatother
\usepackage{pythontex}
\begin{document}
\begin{frame}
\py{2}
\pyv{a}
\end{frame}
\end{document}
生成所需的输出。添加选项alsotrans
后,beamerswitch
现在可以按照我的要求在一次运行中生成演示文稿和幻灯片版本。