从 LuaLaTeX 文档运行 pdflatex.exe

从 LuaLaTeX 文档运行 pdflatex.exe

我的文档组合器通过使用命令pdf的包来组合文件。但在包含之前,先通过编译来生成源。pdfpages\includepdftexpdflatex.exepdf

但是现在我遇到了一点麻烦,我想在输出之前传递一些\LaTeX命令来进行包含。texpdf

我需要更改我的 MWE 的这个字符串

pdflatex.exe -output-directory=\luatexluaescapestring{\fold}  \luatexluaescapestring{\fold/\fold}

pdflatex.exe -output-directory=\luatexluaescapestring{\fold}  "\def\ishandout{1}\luatexluaescapestring{\fold/\fold}"

但它不起作用

\documentclass{article} % combiner
\newcommand{\insertpdf}[1]%
{% #1 is the file name (without extension)
\includepdf[pages=-, link, pagecommand={\pagestyle{plain}}]{#1.pdf}%
    }{\typeout{--- File #1 not found ---}}% 
}
\def\InsertWorkHere#1{%
\edef\fold{#1}
\luadirect{os.execute("

    pdflatex.exe -synctex=1 -time-statistics -interaction=nonstopmode -output-directory=\luatexluaescapestring{\fold}  \luatexluaescapestring{\fold/\fold}

")}
\insertwork{\fold/\fold}
}
\newcommand{\CommandToCompiling}[1]%
{% #1 is the file name (without extension)
    % unknown code here {#1.tex}
    }{\typeout{--- File #1 not found ---}}% 
}
    \begin{document}
    \InsertWorkHere{somefile}

    \end{document}

可能,用 做起来很简单lualatex。此外,将这些命令连接成一个命令也很方便。

答案1

我已经解决了我的问题

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                           %%
%%    Here command for inserting PDF         %%
%%                                           %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\insertwork}[1]%
{% #1 is the file name (without extension)
    \clearpage
    \renewcommand\worktitle{}% reinitialize
    \IfFileExists{#1.dat}{%
        \input{#1.dat}%
        \phantomsection
        \addcontentsline{toc}{chapter}{\textbf{\worknomber.} \worktitle} 
        \includepdf[pages=-, link, pagecommand={\pagestyle{plain}}]{#1.pdf}%
    }{\typeout{--- File #1 not found ---}}% 
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                     %%
%% Here command for combining PDF's before compilation into PDF-book   %%
%%                                                                     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%       
\def\InsertWorkHere#1{%
    \edef\fold{#1}
        \newwrite\flags
        \ifx\flag\@empty{%
        \immediate\openout\flags=\fold/flags.tex
        \immediate\write\flags{\string\PassOptionsToClass{MyClassOption1}{MyClass}}
        }%
        \else
        {
        \immediate\openout\flags=\fold/flags.tex
        \immediate\write\flags{\string\PassOptionsToClass{MyClassOption2}{MyClass}}
        }
        \fi
        \immediate\write\flags{\string\PassOptionsToClass{MyClassOption3}{MyClass}}%
        \immediate\closeout\flags
        \def\compile
        {
        \immediate\write18{pdflatex.exe -interaction=nonstopmode -output-directory="\fold"  \fold}
        \ifluatex
        \luadirect{
        os.execute("e:/Projects/LaTeX/MyPackage/bin/pax.bat '\luatexluaescapestring{\fold/\fold.pdf}' ")
                  }
        \fi
        \insertwork{\fold/\fold}
        }
        \ifx\cflag\@empty
        \compile
        \else
        \IfFileExists{\fold/\fold.pdf}{\insertwork{\fold/\fold}}{\compile}
        \fi
        %\immediate\write18{e:/Projects/LaTeX/MyPackage/bin/pax.bat "\fold/\fold.pdf"}

        \immediate\write18{del /Q "\fold\/flags.tex"}
        }

相关内容