6

The following beamer file compiles fine under the sequence

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}

producing

first sample

(For something more colourful, replace \pyv{a} by e.g. \pyv{float} to get

colourful sample)

However, replacing the class beamer by beamerswitch to get

\documentclass{beamerswitch}

\usepackage{pythontex}

\begin{document}

\begin{frame}

  \py{2}

  \pyv{a}
\end{frame}

\end{document}

fails to render the \pyv output

second sample

I am pretty certain that code of this form worked 1 year ago for me. In comments this has been confirmed for a texlive 2019 set-up.

The problem persists for anything pythontex related to pygments. Using the fancyvrb prettyprinter by calling

\usepackage[prettyprinter=fancyvrb]{pythontex}

gives correct output in both cases.

Any method of fixing the pygments version would be appreciated, as beamerswitch is very useful for my purposes.

Ideas pointing to where the problem may lie, and reports of which systems it does or does not work on, would also be of help. Currently it is not clear to me which component is at fault, so where I can report a bug/issue.

File versions

I am running LaTeX2e <2020-10-01> patch level 4 under texlive 2020 an a mac.

\listfiles produces the long list of file versions below.

Downgrading beamerswitch to version 1.6.1 does not help.

Downgrading pythontex to version 0.16 does not help either.

From comments it appears that the code works in a texlive 2019 set-up.

 *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
 ***********
5
  • I can't reproduce the behavior with a slightly older beamerswitch (1.6.1) and TeX Live 2019, there the 2 and the a both appear normally.
    – Marijn
    Feb 2, 2021 at 22:10
  • @Marijn Thank you. This backs up the fact that this worked for me last year. I am now on Tex Live 2020 and would like it to work in this set-up. Feb 3, 2021 at 8:06
  • @Marjin Unfortunately using beamerswitch (1.6.1) (by placing it in the local directory) does not solve the problem. Feb 3, 2021 at 8:15
  • 1
    I seem to remember that Tex Live 2020 imposes stricter constraints on shell escape than previous versions, maybe this is one of the edge cases that is affected by that - I'll see if I can find more information.
    – Marijn
    Feb 3, 2021 at 8:25
  • @Marijn Thank you. I have now tried looking at the texlive 2020 and don't find anything relevant there. Is there somewhere else one can look for details? Feb 14, 2021 at 10:36

1 Answer 1

6

It turns out the problem comes from beamerswitch including beamer with the option ignorenonframetext. This breaks the pygments support which is included in an \AfterEndPreamble hook. A work around/fix is to do

\makeatletter\mode<presentation>\beamer@ignorenonframefalse\makeatother

after loading the documentclass beamerswitch. So a working example file becomes

\documentclass{beamerswitch}

\makeatletter\mode<presentation>\beamer@ignorenonframefalse\makeatother

\usepackage{pythontex}

\begin{document}

\begin{frame}

  \py{2}

  \pyv{a}
\end{frame}

\end{document}

producing the desired output. Adding the option alsotrans to beamerswitch now produces presentation and slides versions in one run as I require.

3
  • Interesting, do you know how this is related to the difference between TeX Live 2019 and 2020? Or did something change in any of the involved packages/beamer itself?
    – Marijn
    Feb 14, 2021 at 15:44
  • @Marijn I am not sure. I don't currently see relevant changes to the sources of pythontex or beamerswitch. However \AfterEndPreamble of etoolbox now is implemented via the new hooks mechanism. I don't know whether that is relevant. Feb 14, 2021 at 16:56
  • Also currfile.sty has been updated and this is used by pythontex Feb 16, 2021 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .