Decision GuidanceHow is latex compiled and the role of distributions?

Don't know which distribution is the right one for you? Then this is the place to go!
Post Reply
latex_seeker91
Posts: 3
Joined: Tue Apr 04, 2023 10:27 am

How is latex compiled and the role of distributions?

Post by latex_seeker91 »

Hi!
I am new to the forum here. The reason for me joining was a simple query regarding how latex works and how latex distributions work.
I am thinking of taking up the project of making a latex editor. I think a good feature would be to have a latex compiler in-build. That is, I just want the users to install my application from the internet, and it should just work, especially the compilation part. (Without having to install anything else to compile latex). Thus I want a latex compiler in-built in my application.

What is it that I need to provide with my application so that users can compile latex code from the app itself? Do I need to provide a tex distribution like TeXLive or MikTex for this purpose? Or is it something like pdfLatex and latexmk?
I am having a hard time understanding the difference between what texLive does and pdflatex does. It seems to me both are needed to be able to compile latex, but they serve different purposes.

Thanks in advance to the wonderful people of latex community!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How is latex compiled and the role of distributions?

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

Yes, you need a TeX distribution that contains LaTeX. Either on the server, or something on the client side.

On the other hand, you could use the publicly available TeXlive.net, which we use here in the forum. See this example from the LaTeX Cookbook, and click "Run LaTeX here":

Code: Select all

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[sibling distance=10em,
  every node/.style = {shape=rectangle, rounded corners,
    draw, align=center,
    top color=white, bottom color=blue!20}]]
  \node {Formulas}
    child { node {single-line} }
    child { node {multi-line}
      child { node {aligned at}
        child { node {relation sign} }
        child { node {several places} }
        child { node {center} } }
      child { node {first left,\\centered,\\last right} } };
\end{tikzpicture}
\end{document}
Stefan
LaTeX.org admin
latex_seeker91
Posts: 3
Joined: Tue Apr 04, 2023 10:27 am

How is latex compiled and the role of distributions?

Post by latex_seeker91 »

Thanks! TexLive.net seems to be a very good option indeed. Looks like it is quite hassle-free to implement as well.

Coming to client-side solution: Is there a TeX distribution under MIT license (or any other license that lets me freely use it to compile latex)?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How is latex compiled and the role of distributions?

Post by Stefan Kottwitz »

From here: "TeX Live may be freely used, copied, modified, and/or redistributed".

Of course, a full installation requires Gigabytes... but it's as free as it can get, as you see. There are very limited solutions with Javascript and (La)TeX to run in the browser on client side, but then you have not the hundreds or thousands of packages.

TeXlive.net is pretty easy: put a runlatex.js on the server, add some javascript lines to the header, that's pretty much it. The lines in <pre>...</pre> are automatically put into an ace editor on the page, buttons are added for compiling. Texts and buttons can be customized. I use TeXlive.net on Forums, Django sites, WordPress sites, Code/Picture-Galleries, Github Pages, FAQ html pages etc. See or explore this site list. I can setup a site for you if you have serious project and would be interested.

Furthermore, the TeXlive.net maintainers care about the updates. It's already running TeX Live 2023, which has been released just days ago.

Stefan
LaTeX.org admin
latex_seeker91
Posts: 3
Joined: Tue Apr 04, 2023 10:27 am

How is latex compiled and the role of distributions?

Post by latex_seeker91 »

Yeah I agree. The more I look into texlive.net, the more promising it seems.

Just one clarification! I am trying to make a desktop app, not a web app. That is: a latex editor installed on the user's pc (like TexShop).

Anyway, I tried out texlive.net, but haven't figured out how to work with it yet. Tried the following python code:

Code: Select all

import requests
url = "https://texlive.net/cgi-bin/latexcgi"
form_data = {"filename[]":"document.tex", "filecontents[]": "\documentclass{article}\begin{document}\section{Hello}\begin{itemize}\item How are yoou?\end{itemize}\end{document}"}

server = requests.post(url, data=form_data)
output = server.text
print("Response:", output)
The output is:

Code: Select all

Response: Bad form type
So it did not work :(
How does one send compilation requests and also retrieve the compiled pdf using some language, like python for instance?
EDIT: I should perhaps also mention that the HTTP request returns status code 200 (OK).
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

How is latex compiled and the role of distributions?

Post by Stefan Kottwitz »

On TeXlive.net, there should be links to Github where everything is documented.

Stefan
LaTeX.org admin
Post Reply