我有一个多部分的问题。我正在为标准操作程序类文件制作一个类文件。这包括对修订控制标志的需求。
我正在尝试制作一个自定义命令,让您输入更改的日期和文本。该命令应该像以前一样将文本正常地放在文本中,但它使用 changebar 包在右边距中添加了一个修订栏。它还更改了页面样式,将“TCN:日期”添加到页面页脚,其中日期是您在自定义命令中输入的日期。
如果该命令在页面上多次使用,我还想让该命令在页脚中添加两个或更多单独的“TCN:日期”。我完全不知道该怎么做。我原本想在类文件中设置一个程序脚本,但我不知道如何在 LATEX 中做到这一点。
我遇到的一些问题是,当我调用新的自定义命令时,页脚中的日期不会改变,而是保留原始页面样式的设置。当将文本放入命令中时,它变成了一个新段落,而我希望它只是主文本的一部分,就像 \textbf{} 命令的工作方式一样。
这是一个示例 .tex 文件。自定义命令是 \tcnpage,页面样式是 call tcn。
\documentclass[10pt]{test}
\revision{5}
\revisionMMYY{12/93}%Format for the date is MM/YY
\date{7/24/08}
\author{test} %Your Name
\usepackage{lipsum}
\begin{document}
\section{Purpose and Discussion}
\lipsum[1]
\subsection{}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet ligula et pharetra lobortis. Donec felis nisl, sollicitudin ut ligula ac, hendrerit finibus elit. Sed sapien mi, maximus consequat arcu eu, ullamcorper bibendum risus. Pellentesque hendrerit eleifend scelerisque. \tcnpage{1/12}{Aliquam at velit volutpat eros condimentum rutrum.} Fusce est dui, cursus at est at, auctor euismod sapien. Etiam venenatis ornare facilisis. Ut blandit convallis sollicitudin. Phasellus pharetra eros urna, ut suscipit massa feugiat at.
\newpage
\lipsum[1]
\newpage
\subsection{subsection title}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet ligula et pharetra lobortis. Donec felis nisl, sollicitudin ut ligula ac, hendrerit finibus elit. Sed sapien mi, maximus consequat arcu eu, ullamcorper bibendum risus. Pellentesque hendrerit eleifend scelerisque. \tcnpage{4/14}{Aliquam at velit volutpat eros condimentum rutrum.} Fusce est dui, cursus at est at, auctor euismod sapien. Etiam venenatis ornare facilisis. Ut blandit convallis sollicitudin. Phasellus pharetra eros urna, ut suscipit massa feugiat at.
\newpage
\subsection{subsection title}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. \tcnpage{2/13}{Sed imperdiet ligula et pharetra lobortis.} Donec felis nisl, sollicitudin ut ligula ac, hendrerit finibus elit. Sed sapien mi, maximus consequat arcu eu, ullamcorper bibendum risus. Pellentesque hendrerit eleifend scelerisque. \tcnpage{4/14}{Aliquam at velit volutpat eros condimentum rutrum.} Fusce est dui, cursus at est at, auctor euismod sapien. Etiam venenatis ornare facilisis. Ut blandit convallis sollicitudin. Phasellus pharetra eros urna, ut suscipit massa feugiat at.
\end{document}
这是我正在制作的类文件。
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sop}[10/10/2014 article class for standard operating procedures]
% Passes and class options to the underlying article class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}
% Redefine the page margins
\RequirePackage[left=1in,right=1in,top=.75in,bottom=.75in]{geometry}
%Allows for the revision bar in the rigth margin
\RequirePackage[color]{changebar}
\cbcolor{black} %makes the revision bar color black
% For easier construction of page headers/footers
\RequirePackage{fancyhdr}
\newcommand{\revision}[1]{\def\@revision{#1}}
\newcommand{\revisionMMYY}[1]{\def\@revisionMMYY{#1}}
\newcommand{\tcn}[1]{\def\@tcn{#1}}
\fancypagestyle{plain}{ % for first page
\fancyhf{}
\fancyhead[R]{SOP}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{REV \@revision,\ \@revisionMMYY}
\renewcommand{\footrulewidth}{0pt}}
\pagestyle{fancy} % for other pages
\fancyhf{}
\fancyhead[R]{SOP}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{REV \@revision,\ \@revisionMMYY}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{tcn}{ %This style is for any page with a TCN number. Added 11/20/2014 by
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{SOP}
%\thesopchapternumber
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{REV \@revision,\ \@revisionMMYY
\\ TCN: \@tcn}
%\therevision,\ \therevisionMMYY
\renewcommand{\footrulewidth}{0pt}
}
\newcommand{\tcnpage}[2] { % Use this command when wanting to add a TCN to the single page. It takes the form of \tcnpage{DATE} Added 11/20/2014 by
\tcn{#1}
\cbstart
#2
\cbend
\thispagestyle{tcn}
}
\thispagestyle{plain}
\endinput
答案1
我不完全确定我是否正确理解了你的问题和代码,但是这能满足你的要求吗?
\begin{filecontents}{test.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sop}[10/10/2014 article class for standard operating procedures]
% Passes and class options to the underlying article class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}
% Redefine the page margins
\RequirePackage[left=1in,right=1in,top=.75in,bottom=.75in]{geometry}
%Allows for the revision bar in the rigth margin
\RequirePackage[color]{changebar}
\cbcolor{black} %makes the revision bar color black
% For easier construction of page headers/footers
\RequirePackage{fancyhdr,afterpage}
\newcommand{\revision}[1]{\def\@revision{#1}}
\newcommand{\revisionMMYY}[1]{\def\@revisionMMYY{#1}}
\fancypagestyle{plain}{% for first page
\fancyhf{}
\fancyhead[R]{SOP}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{REV \@revision,\ \@revisionMMYY}
\renewcommand{\footrulewidth}{0pt}}
\pagestyle{fancy} % for other pages
\fancyhf{}
\fancyhead[R]{SOP}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{REV \@revision,\ \@revisionMMYY}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{tcn}{%This style is for any page with a TCN number. Added 11/20/2014 by
\fancyhf{}%
\fancyhead[R]{SOP}%
%\thesopchapternumber
\renewcommand{\headrulewidth}{0pt}%
\fancyfoot[R]{REV \@revision,\ \@revisionMMYY
\\ TCN: \@tcn}%
%\therevision,\ \therevisionMMYY
\renewcommand{\footrulewidth}{0pt}}
\newcommand*\tcn[1]{\def\@tcn{#1}}
\def\@tcn{}
\newcommand{\tcnpage}[2] {% Use this command when wanting to add a TCN to the single page. It takes the form of \tcnpage{DATE} Added 11/20/2014 by Joseph Antworth
\edef\@oldtcn{\@tcn}%
\def\tempa{}%
\ifx\tempa\@oldtcn\tcn{#1}\else\tcn{\@oldtcn, #1}\fi%
\cbstart
#2
\cbend
\thispagestyle{tcn}%
\afterpage{\clearpage\gdef\@tcn{}}}
\thispagestyle{plain}
\endinput
\end{filecontents}
\documentclass[10pt]{test}
\revision{5}
\revisionMMYY{12/93}%Format for the date is MM/YY
\date{7/24/08}
\author{test} %Your Name
\usepackage{lipsum}
\begin{document}
\section{Purpose and Discussion}
\lipsum[1]
\subsection{}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet ligula et pharetra lobortis. Donec felis nisl, sollicitudin ut ligula ac, hendrerit finibus elit. Sed sapien mi, maximus consequat arcu eu, ullamcorper bibendum risus. Pellentesque hendrerit eleifend scelerisque. \tcnpage{1/12}{Aliquam at velit volutpat eros condimentum rutrum.} Fusce est dui, cursus at est at, auctor euismod sapien. Etiam venenatis ornare facilisis. Ut blandit convallis sollicitudin. Phasellus pharetra eros urna, ut suscipit massa feugiat at.
\newpage
\lipsum[1]
\newpage
\subsection{subsection title}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet ligula et pharetra lobortis. Donec felis nisl, sollicitudin ut ligula ac, hendrerit finibus elit. Sed sapien mi, maximus consequat arcu eu, ullamcorper bibendum risus. Pellentesque hendrerit eleifend scelerisque. \tcnpage{4/14}{Aliquam at velit volutpat eros condimentum rutrum.} Fusce est dui, cursus at est at, auctor euismod sapien. Etiam venenatis ornare facilisis. Ut blandit convallis sollicitudin. Phasellus pharetra eros urna, ut suscipit massa feugiat at.
\newpage
\subsection{subsection title}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. \tcnpage{2/13}{Sed imperdiet ligula et pharetra lobortis.} Donec felis nisl, sollicitudin ut ligula ac, hendrerit finibus elit. Sed sapien mi, maximus consequat arcu eu, ullamcorper bibendum risus. Pellentesque hendrerit eleifend scelerisque. \tcnpage{4/14}{Aliquam at velit volutpat eros condimentum rutrum.} Fusce est dui, cursus at est at, auctor euismod sapien. Etiam venenatis ornare facilisis. Ut blandit convallis sollicitudin. Phasellus pharetra eros urna, ut suscipit massa feugiat at.
\end{document}