Document ClassesModifying a class

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
artyb
Posts: 2
Joined: Sun Oct 05, 2008 7:21 pm

Modifying a class

Post by artyb »

Hi,
I'm trying to modify the papertex class to allow titles to be spread over just 2 columns of a 3 column environment. The code I'm modifying is:

\newcommand{\magazinetex@inexpandedtitle}[1]{
\begin{minipage}{.95\textwidth}
\begin{center}
\noindent\Large\textbf{#1}
\end{center}
\end{minipage}
}

\newcommand{\expandedtitle}[2]{
\end{multicols}

\begin{center}
\setlength{\fboxsep}{5pt}
\setlength{\shadowsize}{2pt}
\ifthenelse{\equal{#1}{shadowbox}}{%
\shadowbox{%
\magazinetex@inexpandedtitle{#2}%
}%
}{}
\ifthenelse{\equal{#1}{doublebox}}{%
\doublebox{%
\magazinetex@inexpandedtitle{#2}%
}%
}{}
\ifthenelse{\equal{#1}{ovalbox}}{%
\ovalbox{%
\magazinetex@inexpandedtitle{#2}%
}%
}{}
\ifthenelse{\equal{#1}{Ovalbox}}{%
\Ovalbox{%
\magazinetex@inexpandedtitle{#2}%
}%
}{}
\ifthenelse{\equal{#1}{lines}}{
\hrule
\vspace*{8pt}
\begin{center}
\noindent\Large\textbf{#2}
\end{center}
\vspace*{8pt}
\hrule
}{}
\end{center}

\begin{multicols}{\magazinetex@ncolumns{}}
\ifnum \magazinetex@ncolumns > \minraggedcols
\raggedFormat
\fi
}

Clearly here the multicolumn environment is ended, and a minipage of width 0.95textwidth is created. What I'd like to do is get the values of \columnwidth and \columnsep from before we leave the multicolumn environment, and use them to set the width. I've tried \setlength and \let but I get the minipage being very thin. Simply putting \begin{minipage}{10cm} works, but won't adapt to different column widths.
My modification at present:

\newcommand{\papertex@inresultstable}[2]{

\begin{minipage}{\papertex@resultstablesize}
\begin{center}
\noindent\normalsize\textbf{#2}
\end{center}
\end{minipage}
}

\newcommand{\resultstable}[2]{
\setlength{\papertex@previouscolumnwidth}{\columnwidth}
\setlength{\papertex@previouscolumnsep}{\columnsep}
\setlength{\papertex@resultstablesize}{\papertex@previouscolumnwidth}

\vspace*{5pt}

\end{multicols}
\begin{center}




\setlength{\fboxsep}{5pt}
\setlength{\shadowsize}{2pt}

%\addtolength{\papertex@resultstablesize}{-1\papertex@previouscolumnsep}
%\addtolength{\papertex@resultstablesize}{-5pt}
%\addtolength{\papertex@resultstablesize}{-1\shadowsize}





\ifthenelse{\equal{#1}{shadowbox}}{%
\shadowbox{%
\papertex@inresultstable{\papertex@resultstablesize}{#2}%
}%
}{}
\ifthenelse{\equal{#1}{doublebox}}{%
\doublebox{%
\papertex@inresultstable{\papertex@resultstablesize}{#2}%
}%
}{}
\ifthenelse{\equal{#1}{ovalbox}}{%
\ovalbox{%
\papertex@inresultstable{\papertex@resultstablesize}{#2}%
}%
}{}
\ifthenelse{\equal{#1}{Ovalbox}}{%
\Ovalbox{%
\papertex@inresultstable{\papertex@resultstablesize}{#2}%
}%
}{}
\ifthenelse{\equal{#1}{lines}}{
\hrule
\vspace*{5pt}
\begin{center}
\noindent\normalsize\textbf{#2}
\end{center}
\vspace*{5pt}
\hrule
}{}
\end{center}

\begin{multicols}{\papertex@ncolumns{}}
\ifnum \papertex@ncolumns > \minraggedcols
\raggedFormat
\fi
}

I have 2 questions at the moment please. How can I grab and keep a value from before the multicolumn environment was left, and how can I display (either in log file or in LaTeX text output) the value being assigned to variables so that I can debug the class file? Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Modifying a class

Post by Juanjo »

artyb wrote: I have 2 questions at the moment please. How can I grab and keep a value from before the multicolumn environment was left, and how can I display (either in log file or in LaTeX text output) the value being assigned to variables so that I can debug the class file? Thanks in advance.
The following code may help:

Code: Select all

\documentclass{article}

\begin{document}

\newlength{\mylength}
\setlength{\mylength}{10pt}
\the\mylength

\begingroup
\setlength{\mylength}{20pt}
\the\mylength
\endgroup

\the\mylength

\begingroup
\global\setlength{\mylength}{30pt}
\the\mylength
\endgroup

\the\mylength

\end{document}
As shown above, the \the command before a length prints its value. It does the same task for counters: \thepage prints the page number, for example. For macros, you have \show: for example, \show\item stops compilation and shows the actual definition of \item in the console window. Likewise, the above code shows that changes to lengths inside a group are local. Out of the corresponding group, the initial value is reset. If you want to make global some modification, prepend the \global macro.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
artyb
Posts: 2
Joined: Sun Oct 05, 2008 7:21 pm

Re: Modifying a class

Post by artyb »

Brilliant, thank you, and such a quick response-got it working the same evening, but been too busy to thank you since.
Post Reply