0

I'm able to make fmt-files with the packages mylatex or mylatexformat in my Tex Live 2019 installation but I need a file mycalclator.tex for a use case as follows

einitex *mycalculator.tex \dump

that does all the work.

I need a source-file which combines the LaTex format and a preamble with selected LaTeX packages e.g. calculator but also others and several combined for a bare eTeX engine.

Any existing options from the packages should be setable from the application file that will be compiled with the generated format.

Update 31.07.2019

  • only concerns usage of Jim Fowler's Pascal to WebAssembly compiler web2js

Since I still have problems with the memory management of eTeX / LaTeX I'm going to test the answer with plain.tex and eplain.tex.

Dumping eplain per eplain.ini

% Thomas Esser, 1998. public domain.
% hyphenation is set up in language.dat

\input bplain
\input eplain
\dump
\endinput

This would correspond to scenario 2 ( fmt file is not available) but without RequirePackage

  • Could you give an example application about what you mean by that mixing of LaTeX and TeX packages? I don't think changing package options after the package has already been loaded by the format file is possible in general, unless a specific package explicitly defers the options processing e.g. via \AtBeginDocument. – siracusa Jul 21 '19 at 21:18
  • @siracusa I don't think the question mentions any mixing of LaTeX and TeX packages? It also doesn't seem to be asking anything about changing package options. As I understand it, the question is the following: what can I type into a file mycalculator.tex, such that the effect of running einitex *mycalculator.tex \dump (rather than running mylatex or mylatexformat) is to create a format file equivalent to \documentclass{article} \usepackage{calculator} \usepackage{tikz} (or something like that). – ShreevatsaR Jul 21 '19 at 21:24
  • @siracusa ShreevatsaR has put it in a nutshell. I only have an eTeX engine and I need both actions of first loading the LaTex format and second loading a preamble for LaTeX packages defined in this file mycalculator.tex so I can get a special fmt file for my use case. – CarpeDiemKopi Jul 21 '19 at 21:37
  • @CarpeDiemKopi I still don't understand your note about the package options. Do you want to set them in mycalculator.tex or from the actual file that uses the new format? – siracusa Jul 21 '19 at 21:45
  • @siracusa In the actual file that uses the new format. But it doesn't matter for now. I crossed it out in my question. What is important is the basic structure of 'mycalculator.tex`. – CarpeDiemKopi Jul 21 '19 at 21:51
3

For MiKTeX the following sequence gives the desired result, as far as I understand your question (the command-line syntax for TeX Live seems to be a bit different, but I don't have a TeX Live system here to test):

Scenario 1: The latex.fmt format file is already available

  • Create a file mycalculator.tex with the following content:

    \RequirePackage{calculator}
    
  • Run

    etex -initialize "&latex" mycalculator.tex \dump
    

    to create the mycalculator format, based on the latex format.

Scenario 2: The latex.fmt format file is NOT available

  • Create a file mycalculator.tex with the following content:

    \let\origdump=\dump
    \let\dump=\relax
    \input latex.ltx
    \let\dump=\origdump
    \RequirePackage{calculator}
    
  • Run

    etex -initialize mycalculator.tex \dump
    

    to load the LaTeX definitions and create the mycalculator format.

In both cases a user file calctest.tex like

\documentclass{article}

\begin{document}
$\pi \approx \numberPI$
\end{document}

compiled via

etex "&mycalculator" calctest.tex

should result in a .dvi file with the contents

π ≈ 3.14159

  • @CarpeDiemKopi Yes, &latex loads an already existing latex.fmt. In theory you should be able to get the same result by using \input latex.ltx \RequirePackage{calculator} in the format specification. However, that seems to ignore the loading or the calculator package here, and I have no idea why that is happening. – siracusa Jul 22 '19 at 0:44
  • @CarpeDiemKopi Found the problem, please see the update – siracusa Jul 22 '19 at 0:59
  • 2
    Nice answer, +1! With TeX Live (2019), the first scenario can be done with etex -ini '&latex' mycalculator.tex '\dump' (single quote-based quoting depends on the shell, of course, but should be appropriate in most cases). For the second scenario, this is trickier: one apparently has to enable e-TeX's extended mode, otherwise it starts in compatibility mode and latex.ltx won't be loaded fine. This can be done like this: etex -ini '*' mycalculator.tex '\dump'. Note that the '*' is not required (and wouldn't work!) in the first scenario, because... – frougon Jul 22 '19 at 7:18
  • ... “Whenever a format file is loaded by eINITEX or eVIRTEX the mode (compatibility or extended) is inherited from the format” (quote from the e-TeX manual, § 2.2). – frougon Jul 22 '19 at 7:18
  • 1
    @CarpeDiemKopi I don't understand the vocabulary you are using. If you start a LaTeX document with %&latex \documentclass{article} (...), you can compile it with pdftex or pdfetex, as opposed to pdflatex. %&latex tells the TeX engine to load latex.fmt. – frougon Jul 23 '19 at 21:14

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.