我通过 python 计算了一些坐标,以包含 PDF(eStamps)的剪切。我的代码如下所示:
\documentclass[
ngerman, % deutsch-neu
%russian, % russisch
%english, % english
11pt, % Schriftgröße 11pt=Std
a4paper, % DIN A4
oneside, % Einseitig
utf8, % Dateikodierung
]
{g-brief}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{blindtext} % dummytext
\usepackage{picins}
\usepackage[makestderr]{pythontex}
\begin{pycode}
import math
def gen_incl_cmd(zeilen, spalten, n, path):
xLftOff = 22.5
xRgtOff = 27.45
yTopOff = 14.1
yBtmOff = 19.0
xDINA4 = 210.0
yDINA4 = 297.0
xLftStamp = 2.75
xRgtStamp = 7.5
yTopStamp = 11
yBtmStamp = 21.5
xSpacing = (xDINA4 - xLftOff - xRgtOff) / spalten
ySpacing = (yDINA4 - yTopOff - yBtmOff) / zeilen
zeile = math.floor( (n-1) / spalten )
spalte = (n-1) % spalten
if zeile > zeilen:
print('\\fbox{\\parbox[c]{1.7cm}{OUT OF\\\\STAMPS}}')
else:
top = yTopOff + zeile * ySpacing + yTopStamp
left = xLftOff + spalte * xSpacing + xLftStamp
right = xDINA4 - (left + xSpacing) + xRgtStamp
bottom = yDINA4 - (top + ySpacing) + yBtmStamp
print('\\includegraphics[trim={0}mm {1}mm {2}mm {3}mm, clip]{{{4}}}'.format(left, bottom, right, top, path)) # trim=left bottom right top
\end{pycode}
\newcommand{\ePostMarke}[4]{
\parpic[r]{
\pyc{gen_incl_cmd(#1, #2, #3, '#4')}
}
}
\Name {name}
\Strasse {street}
\Ort {zip city}
\Unterschrift {\vspace{-1.7cm}signiture}
\Postvermerk {} % Einschreiben, etc.
\Adresse {
%\ePostMarke{8}{4}{5}{C:/Users/Lenny/Documents/LaTeX/Vorlagen/Briefe/TestPrint}
addr of recipient\\
its street\\
zip and city\\
}
\Betreff {subject}
\Datum {\today}
\Anrede {adress}
\Gruss {greets}{1cm}
\begin{document}
\begin{g-brief}
\blindtext
\ePostMarke{8}{4}{10}{C:/Users/Lenny/Documents/LaTeX/Vorlagen/Briefe/TestPrint}~\\
\ePostMarke{8}{4}{40}{C:/Users/Lenny/Documents/LaTeX/Vorlagen/Briefe/TestPrint}~\\
\pyc{gen_incl_cmd(8,4,10,'C:/Users/Lenny/Documents/LaTeX/Vorlagen/Briefe/TestPrint')}
\blindtext
\end{g-brief}
\end{document}
只要第一行\Adresse
没有注释掉,代码就无法工作。即使文本中包含的 eStamp 也无法工作。
但是如果\Adresse
不受\ePostMarke
命令约束,则每个包含都可以正常工作。 Pythontex 抱怨如下:
Prozess gestartet: "C:/Program Files/MiKTeX 2.9/miktex/bin/pythontex.bat" "D:\Downloads\tex\brief\BRIEF VORLAGE.tex"
This is PythonTeX 0.14
* PythonTeX warning
Unknown option ""
Traceback (most recent call last): File "C:\program files\miktex 2.9\scripts\pythontex\pythontex.py", line 62, in <module> pythontex.main() File "C:\program files\miktex 2.9\scripts\pythontex\pythontex2.py", line 2626, in main load_code_get_settings(data, temp_data) File "C:\program files\miktex 2.9\scripts\pythontex\pythontex2.py", line 475, in load_code_get_settings key, val = line.split('=', 1) ValueError: need more than 1 value to unpack
Prozess endete mit Fehler(n)
我的构建链是
"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex" ?ame" -parse-first-line -shell-escape -enable-write18 -synctex=1 -interaction=nonstopmode | "C:/Program Files/MiKTeX 2.9/miktex/bin/pythontex.bat" ?ame" | "C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex" ?ame" -parse-first-line -shell-escape -enable-write18 -synctex=1 -interaction=nonstopmode | txs:///view-pdf-internal --embedded
如您所见,我使用的是 Win7 x64、MiKTeX 2.9 (x64)。
我期待您的帮助。
答案1
pythontex
这是由于和之间的相互作用造成的g-brief
。环境导致在将文档视为完整之后g-brief
将代码写入pythontex
临时文件。错误是由于试图将代码解析为选项,而它实际上是代码。pythontex
pythontex
如果你\clearpage
在环境结束后插入一个g-brief
,一切都应该正常工作。我打开了一个这个问题,以便在将来的版本中修复该问题pythontex
。