Is it possible to convert my own .cls to .fmt conversion using PdfTeX?

NOTE: Our peoples are frequently change/updations in class file (source .cls file). So that I would like to convert non-editable class format.

  • 5
    look at the mylatexformat package which helps in compiling a custom format based on a document preamble loading specific classes and packages. Sep 2, 2013 at 12:51
  • Did this help? The question is still unanswered.
    – Johannes_B
    Feb 25, 2015 at 18:20
  • Are there any news here? <- for later google search
    – Johannes_B
    Apr 7, 2015 at 15:04
  • Still i have not found the solution. Do you have any ideas?
    – Balaji
    Apr 8, 2015 at 8:56
  • 2
    If the class is frequently changed, then the class should be improved by adding features and easier configurations, fixing bugs, improving documentation, ... Jul 2, 2015 at 12:42

1 Answer 1


Procedure for a format, which has a class preloaded. The class is named theclass in the following.

The class file

Because the class is already loaded in the format, global/class options cannot be specified any longer. Configuration can be implemented by a \theclasssetup command as done by many packages and some classes, e.g. \sisetup of package siunitx or \hypersetup for some of the options of package hyperref.

A dummy class file theclass.cls for testing:

% File: theclass.cls
\ProvidesClass{theclass}[2015/07/02 v1.0 Class for something]

% Implementation of the class


theclass.ini file for the format generation

The new format file consists of LaTeX and the class. The file theclass.ini contain the commands for the format. LaTeX is not loaded, because the available LaTeX formats can be reused. But the class needs to be loaded and \documentclass redefined to allow normal LaTeX documents that can be processed with the format with or without the class preloaded.

% File: theclass.ini
% Check for e-TeX
\expandafter\ifx\csname eTeXversion\endcsname\relax
    \newlinechar=10 %
    \def\space{ }
      The eTeX extension is missing.\MessageBreak
      It can be enabled by option `-etex`\MessageBreak
      or starting the first filename with a star `*'.\MessageBreak
      The format generation is aborted%
  \csname fi\endcsname % end \ifx
  \csname @@end\endcsname % for the case a LaTeX format is already loaded
  \end % end job

% Load class

% Now we have to redefine \documentclass to get valid user documents.
        This format has already loaded the class\MessageBreak
        and does not support global options.\MessageBreak
        The following options are ignored:\MessageBreak
      This format has already loaded the class `theclass'\MessageBreak
      and cannot be used with other classes.\MessageBreak
      LaTeX run is aborted%
    \expandafter\@@end % abort job.
      You have requested,\on@line,
      `#1' of class\space\theclass@name,\MessageBreak
      but only version\MessageBreak
      `\csname ver@\[email protected]\endcsname'\MessageBreak
      is available in this format%

% Format identification
      Class \theclass@name\space \@nameuse{ver@\[email protected]}.%
      Format created at \the\year/\two@digits\month/\two@digits\day
      \space by class author.%

% Generate format

Format generation

This is shown for TeX Live (2015) for pdflatex. Since the format for pdflatex is already available, it is reused by &pdflatex. The special character & usually needs to be escaped on a command line, e.g. \&pdflatex (bash) or "&pdflatex". Option --ini enables iniTeX mode. In this case option --etex is not given, because it is inherited from the imported format file of pdflatex.

pdflatex --ini "&pdflatex" theclass.ini

This generates the format file theclass.fmt. (In the past the extension was .efmt with eTeX extensions.)


Test file:

% or \documentclass{theclass}[2015/07/02]
Hello Word!

The new format theclass.fmt can be loaded with & (should be supported by all TeX compilers):

pdflatex "&theclass" test

Or option --fmt (supported by TeX Live):

pdflatex --fmt=theclass test

Also pdftex could be used, but it uses the wrong search paths for plain format instead of LaTeX. This can be fixed by overwriting the program name:

pdftex --progname=pdflatex --fmt=theclass test


The format file can be found in the current directory or installed in a texmf (TDS) tree. The format file theclass.fmt for engine pdfTeX is installed in:


The root can be the home tree (TEXMFHOME) or a local tree (TEXMFLOCAL). The latter (or MiKTeX) requires the update of the file name database. The programs texhash or mktexlsr can be used in TeX Live for this purpose.

  • I hope you get many upvotes for your effort.
    – Johannes_B
    Jul 2, 2015 at 19:28
  • As an answer to the question, @Johannes_B is surely right. But I worry that the question asked is not the right one. In that sense.... That is, I entirely agreed with your comment on the question but that is not, as it were, reflected at all in the answer....
    – cfr
    Jul 2, 2015 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .