4

I am not sure if the question makes sense; this is my attempt.

I am writing a program that generates a String that is valid LaTeX and compiles it. It will generate a PDF for my users. In my computer I can generate the file as:

pdflatex "my_valid_content_as_a_single_string" 

It works great, for me.

  1. What command should I expect/ask my users to have? Is pdflatex the most available?

  2. How should I ask people to have this available? What is the correct wording? Should they have pdflatex (or whatever command). Or have LaTeX available?

I also need them to have pgfplots, I assume this is always installed by default?

1
  • 1
    Installing something like texlive or MikTeX on a PC isn't done in a minute. So what makes you think that your users would spent so much time, effort and disk space? Commented May 23, 2022 at 9:30

2 Answers 2

6

LaTeX is the generic name of the typesetting system, and the name of the format. Then you have several compilers. I'll just mention a few of them:

  • pdflatex is the historical compiler (although not the first). It's old, I haven't used it for years, but it's still the one that many will consider by default.
  • lualatex is its probable remplacement. It's already mature and widely used, but it requires some changes from the previous one, in habits, code and features.

Which one you call in your command depends heavily on what sort of code your users will compile. While the syntax is independent from the compiler, there are some differences in the libraries you'll load and the commands that will be available. Only your users's needs can tell you what's best.

If your users compile big documents, it's better to call a script like latexmk, which will do its best to make all the calls necessary to generate the document in its final form (there may be several compilations, and calls to external tools).

pgfplots is a very common package, so you should be able to expect its availability in most LaTeX installations. Maybe check with your users which distributions they chose.

2
  • This is very helpful. A bit more context: I have written a PGFPlots code generator. My library creates valid code, I am now missing the last part; show the plot with a show() function. Currently my show() function does the following: run pdflatex "valid_plot_code", then open the output PDF with whatever the default viewer is in their system. Just out of curiosity; is there a way to skip the intermediate file and "pipe" the compiler output to a viewer? Thanks again. Commented May 23, 2022 at 5:45
  • @user17004502 pdflatex is better choice for auto-generating plots because it is significantly faster than lualatex mentioned here. But the best choice is pdftex because it is the fastest and the input code is more simple. It is not LaTeX, it is plain TeX. You need not any \documentclass, \begin{document} etc., just use \relax \input tikz \tikzpicture ... tikz program ...\endtikzpicture \bye in your string. Commented May 23, 2022 at 6:08
5

If the user has tex at all they will (almost certainly) have pdflatex.

The form with the document in a string on the command line is highly non portable though.

pdflatex "my_valid_content_as_a_single_string" 

requires that (at least) " and newlines are escaped in the string and that the commandline removes the outer ". Even on linux the details depend on the user's shell and in other operating systems it may not work at all. (In bash you will need to escape $ if you use " as the outer quotes, but not if you use '

Much safer to write the document to a temporary file then

 pdflatex tempfilename 

The user probably has pgfplots available, in TeX Live it is in collection-picures but if the user installed a restricted scheme such as basic or minimal they won't have it but hopefully they know they installed a restricted scheme and how to use tlmgr to add pgfplots

You could also of course consider not assuming a local tex install at all and provide tex running on a server, and return a PDF given the string in a URL parameter.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.