1

I have kind of a multiple part question. I am making a class file for a standard operating procedure class file. This includes the need for revision control flags.

I am trying to make a custom command that you input the date and text that was changed. The command this is suppose to put the text normally in the text as before but it adds a revision bar in the right margin using the changebar package. Also it changes the page style to add "TCN: date" to the footer of the page with date being the date you entered in the custom command.

I also want to make the command add two or more separate "TCN: date" in the footer if the command is used on a page more than once. I'm not sure how to approach that at all. I was thinking setting up a program script inside the class file but I'm not sure how to do that in LATEX.

Some of the problems I'm running into is the date is not changing in the footer when I call a new custom command instead it stays with whatever the orginal pagestyle was set with. The text, when put in the command, is becoming a new paragraph when I want it to just be apart of the main text much like the \textbf{} command works.

Here is an example .tex file. The custom command is \tcnpage and the pagestyle is 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}

Here is the class file I am making.

 \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
  • I strongly suggest trying to minimise your code. Right now people are going to have to go through a lot of stuff just to understand the problem. A really minimal example, which doesn't include irrelevant stuff, will make it easier for people to help (and so more likely they will help). – cfr Dec 11 '14 at 23:28
  • I will do that. Should a make a new question or just edit this one? – heyjva Dec 12 '14 at 18:39
  • Just edit this one. It will jump back to the top of the 'active' queue and the front page, so will come back to people's attention. Otherwise, your newer one will be in danger of being marked a duplicate of this one. – cfr Dec 12 '14 at 19:01
  • Thank you. I hopefully edited it down to a more reasonable file. – heyjva Dec 15 '14 at 18:22
  • Why are you setting the fancy page style within the definition of the tcn style? – cfr Dec 15 '14 at 18:42
2

I'm not entirely sure I've understood your question and code correctly, but does this do what you want?

\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}

revision info in footers

  • In one part of my document I used the TCNPAGE command around a table. It adds the changebar and the TCN: to the bottom of the page but it does not add the date. Do you know any reason why that happens? I can try and putting together an example if that would make it easier. Thank you. – heyjva Jan 30 '15 at 19:34
  • @heyjva Not offhand, no. But a table is a float, so there is no guarantee that it would end up on the same page anyway. I wouldn't use this for floats. – cfr Jan 30 '15 at 22:25
  • I figured out the problem. For some reason the command fails to print the date inside a \begin{center} environment. Not sure out the fix it but I have a workaround. Thanks for the help! – heyjva Feb 13 '15 at 21:15
  • @heyjva Glad you got it sorted ;). – cfr Feb 13 '15 at 22:14
  • It seems to fail anytime it is in a \begin{} environment. Off the top of your head do you know any reason why that might happen and how I might fix it? If not that's fine. – heyjva Feb 19 '15 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.