1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "latex": `\documentclass[11pt]{article}
12\usepackage[margin=2.5cm]{geometry}
13\usepackage{amsmath,amssymb}
14\usepackage{booktabs}
15\usepackage{tikz}
16\usepackage[colorlinks, allcolors=blue!60!black]{hyperref}
17\begin{filecontents*}{refs.bib}
18@article{knuth1984,
19 author = {Donald E. Knuth},
20 title = {Literate Programming},
21 journal = {The Computer Journal},
22 year = {1984},
23 volume = {27},
24 pages = {97--111}
25}
26\end{filecontents*}
27
28\title{Compiling \LaTeX{} in the Cloud}
29\author{An AI Agent}
30\date{October 2026}
31
32\begin{document}
33\maketitle
34
35\begin{abstract}
36This short paper has equations, a table, a TikZ figure and a citation, all compiled to PDF by one API call.
37\end{abstract}
38
39\section{Results}
40The quadratic formula gives the roots of $ax^2 + bx + c = 0$:
41\begin{equation}
42 x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
43 \label{eq:quadratic}
44\end{equation}
45Equation~\eqref{eq:quadratic} has two real roots when $b^2 > 4ac$, as Table~\ref{tab:cases} shows.
46
47\begin{table}[h]
48 \centering
49 \begin{tabular}{lcc}
50 \toprule
51 Case & Discriminant & Real roots \\
52 \midrule
53 Two roots & $b^2 - 4ac > 0$ & 2 \\
54 One root & $b^2 - 4ac = 0$ & 1 \\
55 None & $b^2 - 4ac < 0$ & 0 \\
56 \bottomrule
57 \end{tabular}
58 \caption{Roots of a quadratic equation.}
59 \label{tab:cases}
60\end{table}
61
62\begin{figure}[h]
63 \centering
64 \begin{tikzpicture}[scale=0.8]
65 \draw[->] (-3,0) -- (3,0) node[right] {$x$};
66 \draw[->] (0,-1.5) -- (0,4) node[above] {$y$};
67 \draw[thick, blue, domain=-2.2:2.2, samples=50] plot (\x, {\x*\x - 1});
68 \fill[red] (-1,0) circle (2pt) (1,0) circle (2pt);
69 \end{tikzpicture}
70 \caption{$y = x^2 - 1$ crosses the $x$-axis twice.}
71\end{figure}
72
73Literate programming~\cite{knuth1984} inspired documents that mix code and prose.
74
75\bibliographystyle{plain}
76\bibliography{refs}
77\end{document}`,
78 "files": []
79};
80
81
82const run = await client.actor("jumblemog/latex-to-pdf").call(input);
83
84
85console.log('Results from dataset');
86console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
87const { items } = await client.dataset(run.defaultDatasetId).listItems();
88items.forEach((item) => {
89 console.dir(item);
90});
91
92