
내가 엄청나게 멍청한 짓을 하고 있는 게 틀림없지만, 운이 없게 될 수 있는 한 최대한 압축해 봤습니다. 최근 커밋에서 발생한 버그를 작업 중입니다.pagectrl
@ca7dc3
.
다음과 같은 최소한의 예가 있습니다.
\documentclass{minimal}
\AtEndDocument{\typeout{wat}}
\begin{document}
hello, world
\end{document}
다음 로그로
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2014.12.7) 9 DEC 2014 22:03
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**\input success-6.tex
(./success-6.tex (/usr/local/texlive/2014/texmf-dist/tex/latex/base/minimal.cls
Document Class: minimal 2001/05/25 Standard LaTeX minimal class
)
No file success-6.aux.
\openout1 = `success-6.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
wat
[1{/usr/local/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./success-6.aux) )
Here is how much of TeX's memory you used:
17 strings out of 493109
369 string characters out of 6135004
52967 words of memory out of 5000000
3574 multiletter control sequences out of 15000+600000
3640 words of font info for 14 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
14i,4n,10p,120b,92s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/local/texlive/2014/texmf-dist/fonts/type1/public/amsfo
nts/cm/cmr10.pfb>
Output written on success-6.pdf (1 page, 11394 bytes).
PDF statistics:
12 PDF objects out of 1000 (max. 8388607)
7 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)
나에게 너무 큰 슬픔을 안겨주는 것은 로그 파일의 다음 부분입니다.
wat
[1{/usr/local/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
나는 이것을 wat
문서가 시작되기 전에 입력된다는 의미로 해석하고 있습니다( [
). 내가 도대체 뭘 잘못하고있는 겁니까?
답변1
후크 \AtEndDocument
는 주로 문서 끝 부분에 인쇄할 자료(예: 주소 또는 메모)에 사용되는 것으로 생각되었습니다.
패키지는 atveryend
이름을 자체 설명하는 두 개의 추가 후크를 제공합니다.
\documentclass{minimal}
\usepackage{atveryend}
\AtEndDocument{\typeout{atend}}
\AfterLastShipout{\typeout{afterlastshipout}}
\AtVeryEndDocument{\typeout{atveryend}}
\begin{document}
hello, world
\end{document}
터미널의 출력은 다음과 같습니다.
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./veryend.tex
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/minimal.cls
Document Class: minimal 2001/05/25 Standard LaTeX minimal class
) (/usr/local/texlive/2014/texmf-dist/tex/latex/oberdiek/atveryend.sty)
(./veryend.aux)
atend
[1{/usr/local/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
afterlastshipout
(./veryend.aux)
atveryend
)</usr/local/texlive/2014/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on veryend.pdf (1 page, 11397 bytes).
Transcript written on veryend.log.
참고하세요atveryend
입력한~ 후에파일 .aux
을 읽었습니다.
답변2
\AtEndDocument
\@enddocumenthook
매크로 내에서 업데이트됩니다 \enddocument
. 다음은 \enddocument
(에서) 의 위치를 보여줍니다latex.ltx
):
\def\enddocument{%
\let\AtEndDocument\@firstofone
\@enddocumenthook% <---- Hook for \AtEndDocument
\@checkend{document}%
\clearpage% <---- Starts the final page builder
\begingroup
\if@filesw
\immediate\closeout\@mainaux
\let\@setckpt\@gobbletwo
\let\@newl@bel\@testdef
\@tempswafalse
\makeatletter \@@input\jobname.aux
\fi
\@dofilelist
\ifdim \font@submax >\fontsubfuzz\relax
\@font@warning{Size substitutions with differences\MessageBreak
up to \font@submax\space have occurred.\@gobbletwo}%
\fi
\@defaultsubs
\@refundefined
\if@filesw
\ifx \@multiplelabels \relax
\if@tempswa
\@latex@warning@no@line{Label(s) may have changed.
Rerun to get cross-references right}%
\fi
\else
\@multiplelabels
\fi
\fi
\endgroup
\deadcycles\z@\@@end}
참고하세요\@enddocumenthook
실행되는~ 전에 \clearpage
, 페이지 빌더를 시작합니다. 따라서,wat
출력된다~ 전에페이지 구축이 시작됩니다. 출력되게 하려면~ 후에, 당신 \clearpage
은 패치 할 수 있습니다\enddocument
(또는 다음의 일부 지침을 따를 수 있습니다).문서의 끝 부분에 연결할 수는 있지만~ 후에?\clearpage
):
\documentclass{article}
\usepackage{etoolbox}
\patchcmd{\enddocument}% <cmd>
{\clearpage}% <search>
{\clearpage\typeout{wat}}% <replace>
{}{}% <success><failure>
\begin{document}
hello, world
\end{document}
보고서 .log
:
[1{/usr/local/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
wat
답변3
패키지 에서 \clearpage
사용하지 않고 최종 문서에 매크로를 배치할 수 있습니다 . 첫 번째 방법은 매우 간단한 경우에 사용할 수 있습니다.\patchcmd
etoolbox
\AtEndDocument{\clearpage\typeout{wat}}
\clearpage
이는 기본 수직 목록에 삭제 가능한 항목만 포함되어 있을 때(즉, 빈 페이지가 생성되지 않을 때) 두 번째(LaTeX 내부에서) 처리되기 때문에 작동합니다 . 그러나 이 방법은 다른 패키지가 사용 \AtEndDocument
하고 해당 매크로가 이전에 처리될 것이라고 가정할 때 실패할 수 있습니다 \clearpage
. 그런 다음보다 강력한 방법을 사용할 수 있습니다. 내부 제어 순서 \afterclearpage
다음에 인수를 이동하는 매크로를 정의합니다 .\clearpage
\documentclass{article}
\def\afterclearpage#1#2\clearpage{#2\clearpage#1}
\AtEndDocument{\afterclearpage{\typeout{wat}}}
\begin{document}
hello, world
\end{document}