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:

    \newcommand{\stopttikzpicture}   {\end  {tikzpicture}    }

    \node [text centered] {it works! \crlf or does it?};

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


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.

  • 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

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.