하나의 단일 .tex 파일에서 여러 PDF 출력

하나의 단일 .tex 파일에서 여러 PDF 출력

다음 MWE 코드는 TexLive2018에서는 완벽하게 작동하지만 "www.overleaf.com"(온라인 Latex 플랫폼)에서는 작동하지 않습니다.

\documentclass{article}

\ifx\conditionmacro\undefined
\immediate\write18{%
    pdfLaTeX --jobname="\jobname1"
    \gdef\string\conditionmacro{1}\string\input\space\jobname
}%
\immediate\write18{%
    pdfLaTeX --jobname="\jobname2"
    \gdef\string\conditionmacro{2}\string\input\space\jobname
}%
\immediate\write18{%
    pdfLaTeX --jobname="\jobname3"
    \gdef\string\conditionmacro{3}\string\input\space\jobname
}%
\expandafter\stop
\fi

\begin{document}
    \ifnum\conditionmacro=1 
    Condition is 1
    \fi
    \ifnum\conditionmacro=2 
    Condition is 2
    \fi
    \ifnum\conditionmacro=3 
    Condition is 3
    \fi
    \verb|\conditionmacro| is \texttt{\meaning\conditionmacro}.
\end{document}

"www.overleaf.com"의 원시 로그는 다음과 같습니다.

이것은 pdfTeX, 버전 3.14159265-2.6-1.40.19(TeX Live 2018)(사전 로드된 형식=pdflatex 2019.8.28)입니다. 2019년 11월 28일 12:59 확장 모드로 전환 \write18 활성화됨. %&-line 구문 분석이 활성화되었습니다. **main.tex (/compile/main.tex LaTeX2e <2018-12-01> (/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls 문서 클래스: 기사 2018/09 /03 v1.4i 표준 LaTeX 문서 클래스(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size10.clo 파일: size10.clo 2018/09/03 v1.4i 표준 LaTeX 파일(크기 옵션) ) \c@part=\count80 \c@section=\count81 \c@subsection=\count82 \c@subsubsection=\count83 \c@paragraph=\count84 \c@subparagraph=\count85 \c@Figure= \count86 \c@table=\count87 \abovecaptionskip=\skip41 \belowcaptionskip=\skip42 \bibindent=\dimen102 ) runsystem(pdfLaTeX --jobname="output1" \gdef \conditionmacro{1}\input 출력).. .executed .

runsystem(pdfLaTeX --jobname="output2" \gdef \conditionmacro{2}\input 출력).. .실행되었습니다.

runsystem(pdfLaTeX --jobname="output3" \gdef \conditionmacro{3}\input 출력).. .실행되었습니다.

) 사용한 TeX 메모리의 양은 다음과 같습니다. 492616 중 198 문자열 6128979 중 2143 문자열 문자 5000000 중 메모리 59595 단어 15000+600000 중 4200 다중 문자 제어 시퀀스 14개 글꼴에 대한 글꼴 정보 3640단어, 8000000 5000i,500n,10000p,200000b,80000s 중 8191 23i,1n,17p,112b,36s 스택 위치 중 9000 1141 하이픈 예외

출력 페이지가 없습니다. PDF 통계: 1000개 중 0개 PDF 개체(최대 8388607) 1000개 중 명명된 대상 0개(최대 500000) 10000개 중 PDF 출력용 추가 메모리 1워드(최대 10000000)

누군가 저를 도와주실 수 있나요??

답변1

(Overleaf 지원팀의 Tom이 글을 쓰고 있습니다.)

Overleaf 설정으로 인해 또는 pdflatex내에서 실행할 수 있지만 파일 이름에 주의해야 합니다. 즉, 이(가 ) 로 설정되어 있지만 기본 파일은 원래 이름을 유지합니다( 아래 예 참조).\immediate\write18\ShellEsc\jobnameoutputmain.tex

따라서 에 의존하는 것은 \input\jobname실제로 불가능하며 \jobname. 또한 pdflatex*nix 시스템에서는 모두 소문자여야 합니다. 마지막으로, 실행으로 생성된 파일에 액세스하는 유일한 방법은 다음을 shell-escape통해입니다.로그 및 출력 파일(오른쪽재컴파일) >기타 로그 및 파일. 거기에 모든 test?.pdf, test?.auxtest?.log파일이 있습니다.

main.tex최소 예( 이 작업을 수행하기 위해 Overleaf에서 호출됨 ):

\documentclass{article}

\usepackage[margin=5pt]{geometry}

\ifx\conditionmacro\undefined
\gdef\conditionmacro{0}
\immediate\write18{
    pdflatex --jobname="test1" "\gdef\string\conditionmacro{1}\string\input\space main"
}
\immediate\write18{
    pdflatex --jobname="test2" "\gdef\string\conditionmacro{2}\string\input\space main"
}
\immediate\write18{
    pdflatex --jobname="test3" "\gdef\string\conditionmacro{3}\string\input\space main"
}
\fi

\usepackage{pdfpages}

\begin{document}
    \centering\fontsize{40}{45}\bfseries
    JOBNAME = \jobname\par
    \ifcase\conditionmacro\relax
        % = 0
        \fbox{\includegraphics[width=9cm]{test1.pdf}}
        \fbox{\includegraphics[width=9cm]{test2.pdf}}
        \fbox{\includegraphics[width=9cm]{test3.pdf}}
    \or
        % = 1
        Condition is 1
    \or
        % = 2
        Condition is 2
    \or
        % = 3
        Condition is 3
    \fi
%    \verb|\conditionmacro| is \texttt{\meaning\conditionmacro}.
\end{document}

관련 정보