我的标签如下:
\documentclass{book}
\newwrite\stylesheetdetails%
\immediate\openout\stylesheetdetails\jobname.ssh%
\AtEndDocument{\immediate\closeout\stylesheetdetails}%
\setlength{\paperheight}{9truein}%
\setlength{\paperwidth}{6truein}%
\immediate\write\stylesheetdetails{Trim size\space\the\paperwidth\space x\space\the\paperheight\space inches}%
\begin{document}
This is for test
\end{document}
我需要获取这些Trim size
值并将其存储在一个扩展名为 的单独文件中.ssh
,我尝试了上述方法,但输出如下:
Trim size 433.62pt x 650.43pt inches
但我需要输出inches
或我给出的任何内容(例如,有时它可能在mm
)而不是point values
,请建议,如何获取它......
答案1
您需要将长度保存在宏中以便写出,但当然仍需设置\paperwidth
并\paperheight
使其对 PDF 产生影响。最好使用短包装器来完成此操作,例如
\documentclass{book}
\newwrite\stylesheetdetails
\immediate\openout\stylesheetdetails\jobname.ssh %
\AtEndDocument{\immediate\closeout\stylesheetdetails}
\newcommand*\savedpaperheight{0pt}
\newcommand*\savedpaperwidth{0pt}
\NewDocumentCommand\setpapersize{mm}{%
\setlength{\paperheight}{#1}%
\setlength{\paperwidth}{#2}%
\renewcommand*\savedpaperheight{#1}%
\renewcommand*\savedpaperwidth{#2}%
}
\setpapersize{9truein}{6truein}
\immediate\write\stylesheetdetails{Trim size \savedpaperheight\space x \savedpaperwidth}
\begin{document}
This is for test
\end{document}