我目前正在设置一封连续信件(即一封信/相同内容,多个收件人)。我当前的脚本将所有页面输出到一个长 PDF 文档中。有没有办法让 LaTeX 为每封信生成单独的 PDF?
主要 TeX 文档:
% !TEX encoding = UTF-8 Unicode
\documentclass[11pt]{g-brief}
\usepackage[utf8]{inputenc}
\usepackage{ngerman}
\usepackage{enumerate}
\usepackage{eurosym}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[arrow, matrix, curve]{xy}
\usepackage{graphicx,type1cm,eso-pic,color}
\lochermarke
\faltmarken
%\fenstermarken
\trennlinien
\Name {My Name}
\Strasse {My Street 123}
\Zusatz {}
\RetourAdresse {}
\Ort {12345 Whereilive}
\Land {}
\Telefon {555-1212}
\Telefax {555-1313}
\EMail {[email protected]}
\Unterschrift {My Name}
\Adresse {
Some \\ Recipient\\Address}
\Betreff {Why am I writing to You today?}
\Datum {\today}
%\IhrZeichen {}
%\IhrSchreiben {}
%\MeinZeichen {cts 20100506.1}
\Anrede {Sehr geehrte Damen und Herren,}
\Gruss {Mit freundlichem Gruss,}{1cm}
\Anlagen {\emph{Anlage: some other page}}
\newcommand{\BriefAn}[5]
{
\newpage
\Adresse{#1 #2\\ #3 \\\\ \textbf{#4}}
\begin{g-brief}
\shorthandoff{"}
I would like to ask you this
\begin{enumerate}
\item yabber yabber
\item somme foobar
\item more yabber
\item more foobar
\item enough of this already
\end{enumerate}
\end{g-brief}
}
\begin{document}
\input{Adressen.tex}
\end{document}
\endinput
Adressen.tex 包含以下内容:
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
答案1
您可以利用此write18
功能并调用pdftk
(pdftk 链接)来自 Latex 内部:
\documentclass{article}
\usepackage{filecontents}
%% ----------------- Your addresses here--------------------------
\begin{filecontents*}{Adressen.tex}
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
\BriefAn{Firstname}{Lastname}{Some Street 314}{12345 Somewhere}{m}
\end{filecontents*}
% ------------------main letter -- letters.tex here--------------------------------
\begin{filecontents*}{letters.tex}
% !TEX encoding = UTF-8 Unicode
\documentclass[11pt]{g-brief}
\usepackage[utf8]{inputenc}
\usepackage{ngerman}
\usepackage{enumerate}
\usepackage{eurosym}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[arrow, matrix, curve]{xy}
\usepackage{graphicx,type1cm,eso-pic,color}
\lochermarke
\faltmarken
%\fenstermarken
\trennlinien
\Name {My Name}
\Strasse {My Street 123}
\Zusatz {}
\RetourAdresse {}
\Ort {12345 Whereilive}
\Land {}
\Telefon {555-1212}
\Telefax {555-1313}
\EMail {[email protected]}
\Unterschrift {My Name}
\Adresse {
Some \\ Recipient\\Address}
\Betreff {Why am I writing to You today?}
\Datum {\today}
%\IhrZeichen {}
%\IhrSchreiben {}
%\MeinZeichen {cts 20100506.1}
\Anrede {Sehr geehrte Damen und Herren,}
\Gruss {Mit freundlichem Gruss,}{1cm}
\Anlagen {\emph{Anlage: some other page}}
\newcommand{\BriefAn}[5]
{
\newpage
\Adresse{#1 #2\\ #3 \\\\ \textbf{#4}}
\begin{g-brief}
\shorthandoff{"}
I would like to ask you this
\begin{enumerate}
\item yabber yabber
\item somme foobar
\item more yabber
\item more foobar
\item enough of this already
\end{enumerate}
\end{g-brief}
}
\begin{document}
\input{Adressen.tex}
\end{document}
\endinput
\end{filecontents*}
%----------------------------------------------------------------
% Compile your document
\immediate\write18{pdflatex letters}
%----------------------------------------------------------------
% Split in to individual pages
%\immediate\write18{pdftk letters.pdf burst allow Printing}
\makeatletter
\immediate\write18{pdftk letters.pdf burst allow Printing output letter-page-\@percentchar02d.pdf}
\makeatother
%----------------------------------------------------------------
\begin{document}
Check for the individual pages in different files with names \verb|letter-page-<page number>| in the same folder as this \verb|.tex| file.
\end{document}
用 编译它。您将获得位于同一文件夹中的pdflatex
4 个同名 pdf 文件。letter-page-<page number>