2

Recently, I am writing a really long book. It spends almost several minutes to complie this tex file. So I have to find some methods to speed up compilation. I've tried some possible ways to speed up compilation, but the results don't seem obvious. For example, \usetikzlibrary{external} help me to reduce some time of compilation. Unchanged tikz figures do not need to be compiled repeatedly.

As far as I know, using precompilation seems to save compilation time even further, especially with some large packages.

Ultrafast PDFLaTeX with precompiling

My question:

I'm using vscode right now. How do I implement latex precompilation in Visual Studio code? (i.e. set up the settings.json)

Maybe some settings are, but I'm not sure:

    "latex-workshop.latex.tools": [
           {
        "name": "etex",
        "command": "etex",
        "args": [
            "-initialize",
            "-interaction=nonstopmode",
            "-jobname=\"pre\"",
            "\"&pdflatex\"",
            "mylatexformat.ltx",
            "\"\"\"%DOC%\"\"\""
        ],
        "env": {}
    },   
]

It come from the issue in LaTeX-Workshop. How to run a custom command? . But I don't know how it relates to precompilation. This may be related to the mylatexformat package.

Any help would be greatly appreciated.

  • Depending on your setup (of which you give no details) you might not win much from using a custom format. Are you using \include + \includeonly as that helps by only compiling selected parts of the code. – daleif May 03 '22 at 14:10
  • @daleif Yes, of course. When I modify a part, I will use \includeonly to confirm the modification result. But eventually I had to run all the files at once, which took a few minutes. For some large packages (i.e. tikz), using precompilation may save a lot of time. – Huanyu Shi May 03 '22 at 14:16
  • It is not the package it self that ears up time, it's the images themselves. I would probably drop externalize and have each tikz image in its own compilable file, and then just include the pdf. Then recompile these from time to time (latexmk can easily compile all files in a folder). But that is just me. – daleif May 03 '22 at 15:32
  • @daleif Thanks for your advice, I will try it later. – Huanyu Shi May 03 '22 at 15:35
  • @daleif But the main drawback of your method is that I cannot change tikz figures globally. For example, if I change the font of a Tex file, those imported PDFs won't change. – Huanyu Shi May 03 '22 at 15:44
  • Why not? You of course have all the figure files (who will use the standalone package) use the same preamble that lives in an external file. Edit there, recompile. – daleif May 03 '22 at 15:46
  • @daleif Oh, I see what you mean. I will try to modify my Tikz file and hope it will compile faster than \usetikzlibrary{external}. Thanks agian for your reply. The best wishes for your. – Huanyu Shi May 03 '22 at 15:51
  • 1
    One advice: always make sure your figures are made in the exact size you're gonna use them, that is no scaling afterwards. If you scale you'll have inconsistent font sizes and line thicknesses which looks unprofessional – daleif May 03 '22 at 15:53

0 Answers0