Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a simple titlepage, which I want to make available for ConTeXt- as well as LaTeX users. Each should just type \usemodule[myTitlepage], or \usepackage{myTitlepage}, respectively.

I want to do this by determining if LaTeX is used, and if so, define all used ConTeXt-macros to their LaTeX equivalents, so that the titlepage can be written in ConTeXt, similar to this:

\ifLaTeX
    \newcommand{\starttikzpicture}[1]{\begin{tikzpicture}[#1]}
    \newcommand{\stopttikzpicture}   {\end  {tikzpicture}    }
    \newcommand{\crlf}{\\}
    ...
\else
    \doConTeXtRelatedStuff
\fi

\starttikzpicture[scale=3]
    \node [text centered] {it works! \crlf or does it?};
\stoptikzpicture

What do I use instead of the pseudocode \ifLaTeX and will the whole idea likely work?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

You can check for some macros that is defined only in LaTeX or ConTeXt. For example, ConTeXt defines \contextformat and \contextversion which hopefully should not be defined by a LaTeX package. Similarly LaTeX defines \documentclass which is not defined by any ConTeXt module.

However, a better solution might be to let kpse choose the format for you. Create a file called mytitlepage.tex in $TEXMF/tex/genereic/.... that contains the common code. Then create a file mytitlepage.sty in $TEXMF/tex/latex/... that contains latex specific code and loads mytitlepage.tex and create a file t-mytitlepage.(tex|mkii|mkiv|lua) in $TEXMF/tex/context/third/... that contains ConTeXt specific code and loads mytitlepage.tex. This way, the right file is chosen depending on the format.

share|improve this answer
    
That's the approach pgf takes: I'd been meaning to post something very similar :-) –  Joseph Wright Sep 12 '11 at 5:58
    
That seems to be a very standard-compliant way of doing it, but it means that I have to develop an install script that puts the files into the user’s texmf tree, instead of simply telling them to drop a single .tex file next to their document in order to install it. But then, I could as well just let the script generate the appropriate file: ./make_titlepage.py latex. A “drop-in” module would be best. –  flying sheep Sep 12 '11 at 10:07
    
@flying sheep: If you want the user to put the package in a local tree, you can just distribute the three files together (in the user directory). If you are asking the user to install on the texmf tree, you can distribute a zip file which has the right TDS structure. You need such a zip file any ways if you upload to CTAN or if you want your users to be able to install the package through texlive or miktex. –  Aditya Sep 12 '11 at 15:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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