[texhax] need name of variable containing value of documentclass

Fehd, Ronald J. (CDC/OCOO/ITSO) rjf2 at cdc.gov
Tue Oct 4 13:27:42 CEST 2011


> From: Fehd, Ronald J. (CDC/OCOO/ITSO)
> Sent: Friday, September 30, 2011 4:36 PM
> To: texhax at tug.org
> Subject: need name of variable containing value of documentclass
> 
> Greetings:
> 
> I am using a file in two different documents:
> the first is a stand-alone doc which is a documentclass=article
> and, after editing, proofreading, and reviewing,
> I will input that file in a larger doc with documentclass=book.
> 
> Q: which macro variable contains the value of documentclass?
> 
> I would like to add the chapter command to the beginning of the file
> when the doc is being input in the documentclass=book
> 
> i.e.:
> if documentclass=book {chapter[\docTitleShort]{\docTitle}}
> 
> thanks
> 
> Ron Fehd  {SAS} macro maven

thank you Heiko Oberdiek for your reply.

I was surprised by the answer that the value of documentclass is not in some variable somewhere.

My solution was relatively easy.
I am developing my suite using a Single-Sourcing model

Single sourcing: building modular documentation [Book] by Kurt Ament i

so I have only two files with documentclass.

in each I added a new variable:

- - - doc-class-article.tex - - -
\documentclass[10pt]{refart}
\newcommand\DocClass{refart}

- - - doc-class-book.tex - - -
\documentclass[10pt]{refrep}
\newcommand\DocClass{refrep}

added \usepackage{ifthen}

after testing this
at the beginning of the chapters

\ifthenelse{\equal{\DocClass}{refrep}}{%
\chapter[\DocTitleShort]{\DocTitle}%
}{\relax}%

and adding this to each part:

\ifthenelse{\equal{\DocClass}{refrep}}{%
\part[\DocTitleShort]{\DocTitle}%
}{\relax}%

I saw that I could make a macro:

\newcommand\addsectioning[1][chapter]{%
\ifthenelse{\equal{\DocClass}{refrep}}%
{\#1[\DocTitleShort]{\DocTitle}}{\relax}}%

which didn't work: \#1 does not expand correctly

final version:

\newcommand\addsectioning[1][chapter]{%
\ifthenelse{\equal{\DocClass}{refrep}}%
{\ifthenelse{\equal{#1}{chapter}}{\chapter}{\part}
[\DocTitleShort]{\DocTitle}}{}}%
%usage:
%\addsectioning%chapter
%\addsectioning[part]

Ron Fehd  {SAS} macro maven




More information about the texhax mailing list