
나는 preview
패키지를 사용하여 환경에서 일부 그림을 생성합니다 equation
. 각 그림의 너비와 높이가 필요합니다. 패키지가 흑마법을 부리는 것 같은데 preview
, 어느 시점에서는 그 값이 알려져야 합니다(?). 순차적으로 텍스트 파일로 저장할 수 있나요?
\documentclass{article}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{equation}
\begin{document}
\begin{equation}
x^2 = 2
\end{equation}
\begin{equation}
\int_0^x \sin t\, dt = 0
\end{equation}
\end{document}
답변1
문서화된 코드를 조사한 결과 후크에 일부 자료를 추가하는 것이 이를 수행하는 방법이라는 preview.sty
것을 알았습니다 (내가 원하는 것은 옵션과 거의 동일합니다). 제가 찾고 있던 치수는 .\pr@ship@end
auctex
\pr@box
치수가 센티미터 단위로 필요하기 때문에 주어진 변환 매크로를 사용했습니다.다른 답변으로.
\documentclass{article}
\usepackage{amsmath}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{equation*}
\makeatletter
% Conversion utility (https://tex.stackexchange.com/a/37317/8425)
\begingroup
\catcode `P=12 % digits and punct. catcode
\catcode `T=12 % digits and punct. catcode
\lowercase{%
\def\x{\def\rem@pt##1.##2PT{##1\ifnum##2>\z@.##2\fi}}}
\expandafter\endgroup\x%
\def\strip@pt{\expandafter\rem@pt\the}
\def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1\relax\relax}
% Answer to the question
\newwrite\file
\immediate\openout\file=snippet-list.txt
\g@addto@macro\pr@ship@end{%
\immediate\write\file{%
\convertto{cm}{\the\dimexpr\ht\pr@box+\dp\pr@box\relax}
\convertto{cm}{\the\wd\pr@box}}}
\begin{document}
Test
\begin{equation*}
x^2 = 2
\end{equation*}
Test
\begin{equation*}
\int x^2\, dx = \frac{x^3}{2}
\end{equation*}
\closeout\file
\end{document}
나는 ~ snippet-list.txt
을 얻는다
0.42175 12.12537
0.86165 12.12537