使用 SVN 信息在页脚中包含源文件名

使用 SVN 信息在页脚中包含源文件名

我使用一组 LaTeX 模板(.tex 文件)来生成多个文档(信函、报告、发票等)。我的所有源文件都在 Tortoise SVN 中进行版本控制,但生成的 pdf 输出文件却没有。

我正在寻找一个选项,当我编译某个 .tex 时file,它filename会打印在 .pdf 输出的某个地方(页眉、页脚)等。我如何在源代码中传递这个参数来包含名称?

例如:我有

  • 模板1 生成字母1、字母2
  • template2 生成 letter3, letter4

由于模板在 SVN 中,我通常在使用后删除编译的文档。当我想重复此过程时,比如几个月后,我必须查看 SVN 日志和源代码以查看我使用了哪一个。

相反,如果我可以在其中一个编译的文档中看到并知道所使用的相应模板,那就太好了。任何帮助都将不胜感激 :)

这是我的代码:

\documentclass[
a4paper,
addrfield = true,
fromalign = right,
foldmarks = true,
backaddress = on, % have backaddress once, see backaddress = plain also
firsthead = false, % remove header at the top
firstheadvpos = 0pt,
enlargefirstpage=true,
]{scrlttr2}

\usepackage{svn-multi}
\svnidlong
{$HeadURL: $}
{$LastChangedDate: $}
{$LastChangedRevision: $}
{$LastChangedBy: $}
\svnid{$Id: $}

\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage{graphicx}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromname}{Addiboy}
\setkomavar{fromaddress}{Germany}
\setlength{\parindent}{0pt}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot[ol]{\jobname}
\fancyfoot[or]{Rev:\svnrev \ (\svnfilerev)}

\begin{document}
    \begin{letter}{Receiver\\
            Timbaktu
        }

        \setkomavar{subject}{Include footer in a letter}

        \opening{Dear fellow TeXnician}

        I am trying to include the footer in the letter template but unable to do so. Furthermore, I would like to integrate some SVN features into this. This works on other pages and other documents except on the opening page of the letter.

        If you solve my problem, the next beer is on me!



        \closing{Yours Sincerely,}
    \end{letter}
\end{document}

答案1

您只需要强制当前页面的页面样式即可。或者,考虑使用 KOMA 工具来设置页脚,这样可能会更干净、更流畅。

\documentclass[
a4paper,
addrfield = true,
fromalign = right,
foldmarks = true,
backaddress = on, % have backaddress once, see backaddress = plain also
firsthead = false, % remove header at the top
firstheadvpos = 0pt,
enlargefirstpage=true,
]{scrlttr2}

\usepackage{svn-multi}
\svnidlong
{$HeadURL: $}
{$LastChangedDate: $}
{$LastChangedRevision: $}
{$LastChangedBy: $}
\svnid{$Id: $}

\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage{graphicx}
\renewcommand*{\raggedsignature}{\raggedright}
\setkomavar{fromname}{Addiboy}
\setkomavar{fromaddress}{Germany}
\setlength{\parindent}{0pt}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot[ol]{\jobname}
\fancyfoot[or]{Rev:\svnrev \ (\svnfilerev)}

\begin{document}
\begin{letter}{Receiver\\\thispagestyle{fancy}
    Timbaktu
  }

  \setkomavar{subject}{Include footer in a letter}

  \opening{Dear fellow TeXnician}

  I am trying to include the footer in the letter template but unable to do so. Furthermore, I would like to integrate some SVN features into this. This works on other pages and other documents except on the opening page of the letter.

  If you solve my problem, the next beer is on me!



  \closing{Yours Sincerely,}
\end{letter}
\end{document}

显然,实际输出的信息并不多,因为文件中没有实际的版本信息,而且\jobname可能对您意义不大。

页脚

相关内容