MacOS:Latexmk 与 Pythontex

MacOS:Latexmk 与 Pythontex

我是 Latexmk 的初学者。Pythontex 通过使用 shell 排版可以正常工作,但我也想使用 Latexmk 进行测试。

我已经和 TexLive 一起安装了它,并且预装了很多规则,包括/usr/local/texlive/2019/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc

当我尝试用 排版时latexmk -xelatex /Users/jowe_19/Desktop/Finle_Name.tex,pythontex 部分不起作用。

分数维:

\documentclass[a4paper]{book}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{pythontex}
%%%%%%%%%%%%
\begin{document}

\begin{pyconsole}
print(1)
\end{pyconsole}

\end{document}

RULE pythontex 预装了 Mactex :

# Support for pythontex in v. 0.16 or higher, with latexmk 4.62 or higher
#
# What these definitions provide/do:
# 1. Variable specifying command string for invoking pythontex
# 2. Addition to %extra_rule_spec of template for pythontex rule. This
#    tells latexmkrc to create the rule when it is initializing for
#    processing a TeX file.
# 3. A subroutine mypythontex that the pythontex rule is defined to
#    call. This runs pythontex and then sets dependency information.
# 4. Settings for the files generated by the pythontex package and the
#    pythontex program so that the files are deleted in a clean-up
#    operation.

$clean_ext .= " pythontex-files-%R/* pythontex-files-%R";
push @generated_exts, 'pytxcode';

$pythontex = 'pythontex --interpreter python:/Users/jowe_19/opt/miniconda3/bin/python3 %O %S';
$extra_rule_spec{'pythontex'}  = [ 'internal', '', 'mypythontex', "%Y%R.pytxcode",  "%Ypythontex-files-%R/%R.pytxmcr",    "%R", 1 ];

sub mypythontex {
   my $result_dir = $aux_dir1."pythontex-files-$$Pbase";
   my $ret = Run_subst( $pythontex, 2 );
   rdb_add_generated( glob "$result_dir/*" );
   my $fh = new FileHandle $$Pdest, "r";
   if ($fh) {
      while (<$fh>) {
         if ( /^%PythonTeX dependency:\s+'([^']+)';/ ) {
         print "Found pythontex dependency '$1'\n";
             rdb_ensure_file( $rule, $aux_dir1.$1 );
     }
      }
      undef $fh;
   }
   else {
       warn "mypythontex: I could not read '$$Pdest'\n",
            "  to check dependencies\n";
   }
   return $ret;
}

日志 :

Latexmk: This is Latexmk, John Collins, 18 June 2019, version: 4.65.
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': The following rules & subrules became out-of-date:
      'xelatex'
------------
Run number 1 of rule 'xelatex'
------------
------------
Running 'xelatex -no-pdf -recorder  "/Users/jowe_19/Desktop/Test_Latexmk.tex"'
------------
This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(/Users/jowe_19/Desktop/Test_Latexmk.tex
LaTeX2e <2019-10-01> patch level 3
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/book.cls
Document Class: book 2019/10/25 v1.4k Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/bk10.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/l3deprecation.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3backend/l3backend-xdvipdfmx.def
))) (/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/tuenc.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/pythontex/pythontex.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/fvextra/fvextra.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v3.4 <2019/11/09> (tvz)
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/upquote/upquote.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/textcomp.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1enc.def)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/lineno/lineno.sty))
(/usr/local/texlive/2019/texmf-dist/tex/generic/xstring/xstring.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xstring/xstring.tex))
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgfopts/pgfopts.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex)))) (/usr/local/texlive/2019/texmf-dist/tex/latex/newfloat/newfloat.sty
) (/usr/local/texlive/2019/texmf-dist/tex/latex/currfile/currfile.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/kvoptions/kvoptions.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2019/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/filehook/filehook.sty)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics-def/xetex.def))
(./Test_Latexmk.aux)
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1cmr.fd)
No file pythontex-files-Test_Latexmk/Test_Latexmk.pytxmcr.
Run PythonTeX to create it.

Package PythonTeX Warning: Non-existent console content on input line 12.

[1] (./Test_Latexmk.aux) )
(see the transcript file for additional information)
Output written on Test_Latexmk.xdv (1 page, 988 bytes).
Transcript written on Test_Latexmk.log.
=== TeX engine is 'XeTeX'
Latexmk: Missing input file: 'pythontex-files-Test_Latexmk/Test_Latexmk.pytxmcr' from line
  'No file pythontex-files-Test_Latexmk/Test_Latexmk.pytxmcr.'
Latexmk: Log file says output to 'Test_Latexmk.xdv'
Latexmk: applying rule 'xdvipdfmx'...
Rule 'xdvipdfmx': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'Test_Latexmk.xdv'
   Rule(s) that have been run and require run of dependent rule:
      'xelatex' which requires run of 'xdvipdfmx'
------------
Run number 1 of rule 'xdvipdfmx'
------------
For rule 'xdvipdfmx', running '&do_viewfile(  )' ...
------------
Running 'xdvipdfmx -o "Test_Latexmk.pdf"  "Test_Latexmk.xdv"'
------------
Test_Latexmk.xdv -> Test_Latexmk.pdf
[1]
4808 bytes written
Latexmk: All targets () are up-to-date

答案1

发生的情况是,用户没有将初始化代码放入 latexmk 默认会读取的初始化文件中。解决方案是将代码放入会读取的文件中。有关可能位置的信息,请参阅 latexmk 文档中的“配置/初始化 (RC) 文件”部分。

相关内容