Hot
- How to modify the chapter headings using \EditInstanceby polaren on March 16, 2026 at 4:50 pm
I'm trying to make a \chapter (and \chapter*) heading looking like the picture below. The document must be accessible, so I'm using the \EditInstance command. With the following code (found pretty much by trail and error) \EditInstance{heading}{chapter}{ number-format=\makebox[12mm][l]{\theheading.}, number-decls=\sffamily\fontsize{14pt}{16pt}\selectfont, title-decls=\sffamily\fontsize{14pt}{16pt}\selectfont, after-sep=0mm, before-sep=0mm, start-code=\clearpage\vspace*{-10.75mm}\rule{\textwidth}{0.1mm}\newline\vspace*{-18mm}, final-code=\vspace*{-5mm}\rule{\textwidth}{0.1mm}\newline\vspace*{4mm}, headformat-instance=hang, decls=\raggedright\parindent 0pt\rmfamily } I get something that looks okay, but I strongly suspect this is far from the best way to do this. For example, this solution depends on the value of \parskip which doesn't seem right (I have \parskip set to 6pt). Also, the \vspace commands indicate this isn't done right. Any suggestions on how to do this more robustly are most welcome. I'm using lualatex-dev on Windows/MikTeX: "This is LuaHBTeX, Version 1.24.0 (MiKTeX 26.2)".
- Trimming causes compilation failureby BambOo on March 16, 2026 at 2:59 pm
I'm using https://tex.stackexchange.com/a/647838/141947 to operate over a list of image files to include them easily in a document. For some reason, adding a trim option to \includegraphics results in a compilation failure with File ended while scanning use of \Gread@parse@vp Why does it break ? MWE \documentclass{article} \usepackage{graphicx} \ExplSyntaxOn \NewDocumentCommand{\plotloop}{O{.}m} {% #1 = common prefix, default . for the current directory % #2 = list of file names \clist_map_inline:nn { #2 } { \begin{figure}[p] \centering \includegraphics[scale=1, angle=90]{example-image-##1} % Works % \includegraphics[scale=1, angle=90, trim={0cm 0cm 0cm 0cm},clip]{example-image-##1} % Fails \caption{Left~\protect\detokenize\expandafter{example-image-##1}} \end{figure} \begin{figure}[p] \centering \includegraphics[{scale=1, angle=90}]{example-image-##1} \caption{Right~\protect\detokenize\expandafter{example-image-##1}} \end{figure} } } \ExplSyntaxOff \begin{document} \plotloop{a,b,c} \end{document}
- How should (0,-1) -- +([turn]45:2) be interpreted?by D G on March 16, 2026 at 11:57 am
How should I interprete the case B? Case A \documentclass[tikz,border=12pt,12pt]{standalone} \begin{document} \begin{tikzpicture}[dot/.append style={circle,fill,inner sep=3pt}] \draw (-3,-3) grid (3,3); \draw[line width=3pt] (-3,-1) coordinate[dot] -- (0,-1) coordinate[dot] -- ([turn]45:{sqrt(2)}) coordinate[dot]% turn 45 degrees relative to the previous segment direction -- ([turn]90:3) coordinate[dot]; \path (0,0) coordinate[dot,red]; \end{tikzpicture} \end{document} Case B \documentclass[tikz,border=12pt,12pt]{standalone} \begin{document} \begin{tikzpicture}[dot/.append style={circle,fill,inner sep=3pt}] \draw (-3,-3) grid (3,3); \draw[line width=3pt] (-3,-1) coordinate[dot] -- (0,-1) coordinate[dot] -- +([turn]45:{sqrt(2)}) coordinate[dot]% how should this line be interpreted? -- ([turn]90:3) coordinate[dot]; \path (0,0) coordinate[dot,red]; \end{tikzpicture} \end{document}
- Figures in margins and example boxesby Dmitry Vysochinskiy on March 16, 2026 at 11:48 am
I am currently working on a revised edition of an older book. The author insists on keeping the original formatting style, which includes: examples placed inside colored boxes, and figures placed in the margins. I have been able to put the figures in the margins using the tufte-book class. I have also placed the example text inside boxes using the tcolorbox package. For pure‑text examples, I even managed to make some boxes span the full page width. The problem appears when I have an example box that contains full text and a figure that must go into the margin. I cannot figure out how to create a colored box that spans the full page width but still leaves space for a margin figure inside it. In other words: how can I preserve the original text layout (main text + margin figure) and place a colored box behind it? Any suggestions on how to achieve this in tufte-book or with tcolorbox would be greatly appreciated.
- How can I avoid having to delete the .aux file every time I add a new question?by Laurenso on March 16, 2026 at 11:05 am
I have the following code. Every time I add a new question, I need to delete the .aux file for the changes to take effect. How can I avoid deleting the .aux file each time I add a new question? Shuffle questions in xsim
- Use the main font in math mode (Roboto serif)by Thomas on March 16, 2026 at 9:13 am
I'm writing a document using the font roboto-serif, and I struggle setting the same font to the math mode. Here is an MWE : \documentclass{article} \usepackage{amsmath, amssymb} \usepackage{roboto-serif} \begin{document} Here is a formula : $I_\text{Gauss} :=\displaystyle\int_{-\infty}^{+\infty} \mathrm e^{x^2}\mathrm d x=\sqrt{\pi}$ \end{document} And here is the result : We see that the text is in Roboto font, as well as the content of \text in math mode, but the other symbols are in the default math font. The difference is more striking in my full document with paragraph of text and big formulas. I'm quite sure I'm note the first one writing this question, but it's been a few hours I'm looking online and did not manage to find a solution working for me... Either solution setting a sans serif font for math only (visually worst than the present one), or not working solution (it's the first time I'm trying LuaLaTex, that may explain why). NB: I can change the main font for my document, as long as the math mode is coherent with it (ideally, I'd like to use a serif font, different of the default one, but I'm open to something else)
- DocumentMetadata impeding the processing of otherwise normal fileby Knudsen on March 16, 2026 at 5:38 am
I have an MWE that when processed (lualatex) produces an error ! Argument of \__math_grab_dollar_delim:w has an extra }. which, as far as I know, is not true and impedes the processing of the file. When you comment the DocumentMetadata statement line, the file process fine and produces a PDF fine. \DocumentMetadata{pdfversion=1.7, pdfstandard=A-2b, lang=en-US} \documentclass{report} \usepackage{tikz-cd} % Enable modern LaTeX3 programming syntax \ExplSyntaxOn \NewDocumentCommand{\testinput}{ m } { \file_input:n { #1 } } \ExplSyntaxOff \begin{filecontents*}{diag.tex} \begin{tikzcd}[sep = .8 cm] S^2 \arrow[d, "\pi"] \arrow[r, "\pi"] & (P^2,d) \\ P^2 \arrow[ru, "{\overline{\pi}}"] \end{tikzcd} Since $P^2$ is compact... \end{filecontents*} \begin{document} \testinput{diag.tex} \end{document} I read the DocumentMetadata documentation and it mostly says that the command is a statement, and does not elaborate on the implications that it may have on the processing of the file. The numbers I choose for the example only implies that when you save a file as PDF/A-2b, you are creating a PDF 1.7 file that has been stripped of prohibited features (like JavaScript, encryption, and external references). How does one determine what allows the file to be processed and what not?
- Longtable cell content exceeds column width and alignment seems wrong in custom table setupby user516076 on March 16, 2026 at 4:17 am
I am defining a custom longtable environment for a mark scheme table. The first table below is included only to show that the repeated header works correctly across pages, and also to compare the behaviour when the cells contain \lipsum text versus manually written content. The problem appears in the second table. In the last column, the text can extend outside the cell and appear beyond the table boundary. Also, the vertical and horizontal alignment do not seem to behave as expected. I would like to understand why this happens, not only how to fix it. Here is a minimal working example. try.tex \documentclass[12pt]{article} \usepackage[a4paper,margin=2cm]{geometry} \usepackage{array} \usepackage{longtable} \usepackage{lipsum} \usepackage{pdflscape} \usepackage[table]{xcolor} \usepackage{amsmath} \newlength{\MSAnswerWidth} \newlength{\MSPartialWidth} \newcommand{\MSComputeWidths}{% % Desired layout: % | 2cm | x | 2cm | y | % with x = y + 2cm % and the whole table spanning \linewidth \setlength{\MSPartialWidth}{% \dimexpr(\linewidth - 6cm - 8\tabcolsep - 5\arrayrulewidth)/2\relax }% \setlength{\MSAnswerWidth}{\dimexpr\MSPartialWidth + 2cm\relax}% } \newcommand{\MSHead}[2]{% \cellcolor{cyan!35}% \parbox[c][3.2em][c]{#1}{\centering\bfseries #2}% } \newcommand{\MSHeaderRow}{% \hline \MSHead{2cm}{Question} & \MSHead{\MSAnswerWidth}{Answer} & \MSHead{2cm}{Marks} & \MSHead{\MSPartialWidth}{Partial Marks} \\ \hline } \newenvironment{MarkSchemeTable}{% \MSComputeWidths \setlength{\LTleft}{0pt}% \setlength{\LTright}{0pt}% \renewcommand{\arraystretch}{1.15}% \begin{longtable}{|>{\centering\arraybackslash}p{2cm}|>{\raggedright\arraybackslash}p{\MSAnswerWidth}|>{\centering\arraybackslash}p{2cm}|>{\raggedright\arraybackslash}p{\MSPartialWidth}|} \MSHeaderRow \endfirsthead \MSHeaderRow \endhead \hline \endfoot \hline \endlastfoot }{% \end{longtable} } \newcommand{\MSRow}[4]{% #1 & #2 & #3 & #4 \\ \hline } \begin{document} \begin{landscape} \input{try2} \end{landscape} \end{document} and try2.tex \noindent\textbf{Test table} \vspace{3mm} \begin{MarkSchemeTable} \MSRow{1(a)}{\lipsum[1][1-4]}{M1}{\lipsum[2][1-2]} \MSRow{1(b)}{\lipsum[3][1-4]}{A1}{\lipsum[4][1-2]} \MSRow{2(a)}{\lipsum[5][1-4]}{B1}{\lipsum[6][1-2]} \MSRow{2(b)}{\lipsum[7][1-4]}{M1}{\lipsum[8][1-2]} \MSRow{3(a)}{\lipsum[9][1-4]}{A1}{\lipsum[10][1-2]} \MSRow{3(b)}{\lipsum[11][1-4]}{B1}{\lipsum[12][1-2]} \MSRow{4(a)}{\lipsum[13][1-4]}{M1}{\lipsum[14][1-2]} \MSRow{4(b)}{\lipsum[15][1-4]}{A1}{\lipsum[16][1-2]} \MSRow{5(a)}{\lipsum[17][1-4]}{B1}{\lipsum[18][1-2]} \MSRow{5(b)}{\lipsum[19][1-4]}{M1}{\lipsum[20][1-2]} \end{MarkSchemeTable} \begin{MarkSchemeTable} \MSRow{1}{$80\text{ m}$}{3}{\shortstack[l]{M1 for $40 \div 10 = 4\text{ m per cm}$ or scale factor $=4$\\ M1 for $2(4+6)=20\text{ cm}$ or perimeter of drawing $=20\text{ cm}$\\ A1 for $20 \times 4 = 80\text{ m}$}} \end{MarkSchemeTable} My questions are: Why does the content in the fourth column of the second table extend beyond the cell boundary? Why do the vertical and horizontal alignments appear inconsistent in this setup? What is the correct way to enter multi line content in such a cell without breaking the table layout? I am especially interested in the reason this behaves differently from the \lipsum rows. The codes above render to: Using \lipsum gives a cleaner and neater result, but when I enter the content manually, the second table becomes problematic. Thank you in advance. EDIT: Also it's worth mentioning that I use \shortstack[l] because \\ in one cell will not make a newline, instead, in my code, it will make the next stuff goes to the next cell instead. The default alignments that I set before are: for first and third column after the header, it will be horizontally aligned and start from top. the second and fourth column will start from left top (left-aligned)
- Beamer: Align content to top when having text and bullet listby edjmir on March 16, 2026 at 3:14 am
I wonder if there's a way to align the content of two columns in a Beamer doc. I have this MWE \documentclass{beamer} \begin{document} \begin{frame}{Frame title} \begin{columns}[t] \begin{column}{0.3\textwidth} \bfseries\centering Facilitates \end{column} \begin{column}{0.7\textwidth} \begin{itemize} \item Second column, first item \end{itemize} \end{column} \end{columns} \end{frame} \end{document} I see that the solution with the minipage environment works pretty well, but I was wondering if there's an alternative using columns. The alignment using columns works when both are text or bullet lists, but when they are mixed, it doesn't work. I even tried the solution with the custom environment, but it didn't work. \newenvironment{myitemize}
- add an extra table column for alternative representation of quantitiesby Roel on March 15, 2026 at 9:48 pm
The package siunitx has many nice features to make 'raw' numerical data publication ready. especially being able to change the rounding, formatting of the exponent and changing the units (multiplication, offset by 273.15, etc.) make it possible to fix many formal shortcomings of a draft table, without touching the actual data in the table. In a similar vein, would it be possible to add a derived quantity after an existing one; e.g. could one change the column specification of this table: \begin{tabular}{ S[table-format=3.0] } \toprule {$T / \unit{\kelvin}$} \\ \midrule 300 \\ 250 \\ \bottomrule \end{tabular} so that it looks like the one below? \begin{tabular}{ S[table-format=3.0] S[table-format=-2.0] } \toprule {$T / \unit{\kelvin}$} & {$t / \unit{\celsius}$} & \\ \midrule 300 & 26.85 250 & -23.15 \bottomrule \end{tabular}
- Elegant Visualizations for Volumes of Revolution in Calculus II Notesby Ahed on March 15, 2026 at 5:14 pm
I’m preparing handwritten-style notes for my Calculus II class (topics like disk/washer method, shell method, etc.), and I would like to include nice visualizations of solids of revolution. Does anyone have suggestions for elegant ways to present volumes of revolution in lecture notes? For example: good diagrams or visualization tools, LaTeX/TikZ packages, Python/Matlab plots, interactive graphics (GeoGebra, Desmos, etc.). My goal is to make the geometry of the solid very clear for students (cross-sections, rotation around the axis, comparison of disk vs washer vs shell). Any suggestions or examples would be greatly appreciated. Thank you!
- makeindex --- command \see already definedby underflow on March 15, 2026 at 2:11 pm
I want to create an index of terms, but makeindex returns a mysterious error. Here is a MWE: \documentclass[12pt,oneside]{amsbook} \usepackage{makeidx} \makeindex \begin{document} \index{testme} Test sentence. \printindex \end{document} Here's the error message: (/usr/share/texlive/texmf-dist/tex/latex/base/makeidx.sty Package: makeidx 2021/10/04 v1.0m Standard LaTeX package ! LaTeX Error: Command \see already defined. Or name \end... illegal, see p.192 of the manual. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.46 \newcommand*\see[2]{\emph{\seename} #1} ? s OK, entering \scrollmode... ! LaTeX Error: Command \printindex already defined. Or name \end... illegal, see p.192 of the manual. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.48 ...command\printindex{\@input@{\jobname.ind}} Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without it. ) I'm at a lost of what to do. Your advice is most appreciated. Thanks!
- How to get list of installed packages of previous TeX Live installation?by ViToni on March 15, 2026 at 12:35 pm
Recently I switched from TeX Live 2025 to TeX Live 2026. As this is a basic installation I now recognizes that the installations are independent and don't share a list of previously installed packages. I'd like to prevent to have to install everything or go package by package until everything compiles. Is there a way to get the list of installed packages from the previous installation? I'm using MacTeX and I fail to use tlmgr by their full path (and by that using them independently) e.g. to get a list of installed packages: Getting the real path: ❯ which tlmgr /Library/TeX/texbin/tlmgr ❯ realpath /Library/TeX/texbin/tlmgr /usr/local/texlive/2026basic/texmf-dist/scripts/texlive/tlmgr.pl tlmgr for TeX Live 2026: ❯ /usr/local/texlive/2026basic/texmf-dist/scripts/texlive/tlmgr.pl Can't locate TeXLive/TLConfig.pm in @INC (you may need to install the TeXLive::TLConfig module) (@INC contains: /usr/local/texlive/2026basic/texmf-dist/scripts/texlive/../../texmf-dist/scripts/texlive /usr/local/texlive/2026basic/texmf-dist/scripts/texlive/../../tlpkg /Library/Perl/5.34/darwin-thread-multi-2level /Library/Perl/5.34 /Network/Library/Perl/5.34/darwin-thread-multi-2level /Network/Library/Perl/5.34 /Library/Perl/Updates/5.34.1 /System/Library/Perl/5.34/darwin-thread-multi-2level /System/Library/Perl/5.34 /System/Library/Perl/Extras/5.34/darwin-thread-multi-2level /System/Library/Perl/Extras/5.34) at /usr/local/texlive/2026basic/texmf-dist/scripts/texlive/tlmgr.pl line 94. BEGIN failed--compilation aborted at /usr/local/texlive/2026basic/texmf-dist/scripts/texlive/tlmgr.pl line 94. tlmgr for TeX Live 2025: ❯ /usr/local/texlive/2025basic/texmf-dist/scripts/texlive/tlmgr.pl Can't locate TeXLive/TLConfig.pm in @INC (you may need to install the TeXLive::TLConfig module) (@INC contains: /usr/local/texlive/2025basic/texmf-dist/scripts/texlive/../../texmf-dist/scripts/texlive /usr/local/texlive/2025basic/texmf-dist/scripts/texlive/../../tlpkg /Library/Perl/5.34/darwin-thread-multi-2level /Library/Perl/5.34 /Network/Library/Perl/5.34/darwin-thread-multi-2level /Network/Library/Perl/5.34 /Library/Perl/Updates/5.34.1 /System/Library/Perl/5.34/darwin-thread-multi-2level /System/Library/Perl/5.34 /System/Library/Perl/Extras/5.34/darwin-thread-multi-2level /System/Library/Perl/Extras/5.34) at /usr/local/texlive/2025basic/texmf-dist/scripts/texlive/tlmgr.pl line 92. BEGIN failed--compilation aborted at /usr/local/texlive/2025basic/texmf-dist/scripts/texlive/tlmgr.pl line 92.
- Theorem citation style [duplicate]by Davide on March 15, 2026 at 12:23 pm
I would like to cite theorems in my manuscript by specifying the reference in the theorem title. I tried using the following code: \begin{theorem}[{\cite[Thm.~2.5]{reference_paper}}] Statement of the theorem \end{theorem} or \begin{theorem} \cite[Thm.~2.5]{reference_paper}. Statement of the theorem \end{theorem} These produce the first two results shown in the attached image, but I would prefer something similar to the third row. Being able to remove the space after '(' in the first example would also be fine. Do you have any suggestions? Thanks in advance!
- Pandoc template error "unexpected $" or "unexpected end of input" — caused by `$if$`/`$endif$` inside LaTeX `%` commentsby Marek Kowalczyk on March 15, 2026 at 11:08 am
I'm editing a custom Pandoc LaTeX template (default.latex). After adding comments to document my changes, Pandoc refuses to compile the template. Depending on the comment, I get one of two errors. Error 1 — orphaned $endif$ in a comment: % fixes the $endif$ bug pandoc: "template" (line 5, column 15): unexpected "$" expecting letter or digit or "()" Error 2 — unclosed $if(...)$ in a comment: $endif$ % end $if(title)$ pandoc: "template" (line 877, column 15): unexpected end of input expecting "$--", "\n", "$", "${" or "$$" Both are fatal. What's going on, and how do I safely comment a Pandoc LaTeX template?
- How to include another later document with its own document class in a larger latex documentby AnAnonymousCrocodile on March 15, 2026 at 8:22 am
For context, I am trying to include my cv, typeset with the document class moderncv, inside a larger application document. Is there any effective way of handling this ? (Most of the document inclusion package I have seen seem to be meant to drop the preamble and documentclss of included documents.)
- Three column layout with spann floatsby GowriSaro on March 14, 2026 at 4:48 pm
Is it possible to get three column layout in LaTeX as like as \documentclass[twocolumn]{article} I don't want to use multicols package, as it might have issues with floats. Also, please suggest that spanning of two column floats and three column floats and footnotes are possible. First page layout sample: Image/Table which span to two column: Image/Table which span to all three column: Image/Table in one column:
- Counting a specific token inside a token listby Vincent on March 14, 2026 at 4:32 pm
The following code is meant to count the number of tokens in a token list: \documentclass{article} \ExplSyntaxOn \NewExpandableDocumentCommand{\tokencount}{o m}{ \__tokencount_count_tokens:nn{#2}{#1} } \cs_new:Npn \__tokencount_count_tokens:nn #1#2{ \int_eval:n{ 0 \tl_map_tokens:nn{#2}{\__tokencount_count_token:nn{#1}} } } \cs_new:Npn \__tokencount_count_token:nn #1#2{ \tl_map_tokens:nn{#1}{\__tokencount_count_token_compare:nn{#2}} } \cs_new:Npn \__tokencount_count_token_compare:nn #1#2{ \tl_if_eq:nnT{#1}{#2}{ +1 } } \ExplSyntaxOff \begin{document} \noindent \tokencount[-]{1-2-3}\\ % Should return 2, but returns 0 + 1 + 1 \tokencount[-,]{1-2-3,4,5,6}\\ % Should return 5, but returns 0 + 1 + 1 + 1 + 1 + 1 \tokencount[ {ab} ]{1{ab}2{ab}3}\\ % Should return 2, but returns 0 + 1 + 1 \tokencount[ {ab} - ]{1{ab}2{ab}3-4}\\ % Should return 3, but returns 0 + 1 + 1 + 1 \end{document} Three questions: Q1: How to make it work correctly? Q2: How to improve it/make it more robust if necessary while keeping it expandable? Q3: How to optimize it to minimize compile time?
- ConTeXt: Control spacing around multiple footnote apparatusesby Jeff Dodson on March 14, 2026 at 4:14 pm
My goal is to typeset a document in ConTeXt with grid/line-matching, and with two "serried" footnote apparatuses at the bottom. The top footnote apparatus I name as "marginal" with \definenote[marginal] and the lower apparatus I name as \definenote[critical]. On any given page, you might see no footnotes at all, you might see one of the apparatuses but not the other, or you might see both together. Regardless, I'd always like to see exactly one grid line of space between the last line of text from the main text body and the horizontal rule of whichever footnote apparatus appears on top. So if the "marginal" apparatus appears on a page, I'd like to see one grid line of space between its horizontal rule and the main text. However, on a page where the "marginal" apparatus doesn't appear at all, but the "critical" apparatus does appear, I'd of course like to see that one line of empty space appear between the bottom of the main text block and the horizontal rule of the "critical" apparatus. If both apparatuses appear on a page, I don't want to see any extra space between the two apparatuses themselves. In other words, in order to make this work, I need some sort of spacing that can automatically vary depending on which apparatuses appear on any given page. However, although I used to have a ConTeXt setup that seemed to accomplish this, several days ago I updated to the latest ConTeXt release, and it completely broke my entire footnote system. Specifically, strange space now appears between my two apparatuses, too much space sometimes appears between the main text body and the top apparatus, and at times the top apparatus of footnotes actually overlaps the bottom of the main text body. Note that before this most recent update, I had never seen ConTeXt cause a footnote apparatus to overlap the main text as shown here. The version of ConTeXt I'm using is "2026.02.19 11:49". I've included a minimum working example here that demonstrates the overlap I'm seeing. So I have two specific questions I'm posing here: (1) In such a simple MWE with no frills, why is ConTeXt overlapping a footnote apparatus with the main text body? and (2) Give the variable spacing requirements I listed above, can this MWE be modified to accomplish those spacing requirements? To summarize, here is what I was trying to accomplish with the two apparatuses: "marginal" apparatus on top, assuming it appears on a given page "critical" apparatus either on top or bottom (depending on whether or not the "marginal" apparatus appears on that page) All notes in paragraph, run-on (i.e., "serried") form Footnote text can be ragged-right rather than justified Whichever apparatus appears on top, I'd like to see one line of grid space between the bottom of the main text block and the horizontal rule of the top apparatus. If both apparatuses appear on a page, I'd like to see no extra space between the two apparatuses (although they would be separated by a horizontal rule). \setuppapersize [A5] \setuplayout [tight] \setuplayout [grid=yes] \setupinterlinespace [line=5ex] \definenote[marginal] \setupnote [marginal] [alternative=serried, paragraph=yes, location=page] \setupnotation [marginal] [number=no] \definenote[critical] \setupnote [critical] [alternative=serried, paragraph=yes, location=page] \setupnotation [critical] [number=no] \starttext \samplefile{knuth}\marginal{1. \samplefile{knuth}}\critical{2. Some more footnote text.}\samplefile{knuth} \samplefile{knuth}\marginal{1. \samplefile{knuth}}\critical{2. Some more footnote text.}\samplefile{knuth} \samplefile{knuth}\marginal{1. \samplefile{knuth}}\critical{2. Some more footnote text.}\samplefile{knuth} \stoptext Here is the output produced by this MWE, where you can see the two apparatuses appearing, but with the top apparatus overlapping the main text: [UPDATE] In light of the request to look at the beyond-inserts.tex documentation: I did read it in full. However, I don't understand how it helps me figure out how to accomplish the spacing around my notes that I'm trying to achieve. But in the spirit/style of that documentation, I'll reiterate what I'm trying to do: This image shows what I'm trying to achieve if both footnote apparatuses appear on a single page. In this case, there's one line of grid space between the main text body and the first block of notes, with the horizontal rule for the notes falling on a grid line. Then there's no extra space between the top and bottom apparatuses. And all note text falls along grid lines, just like the main text body. Now here's the case where the top apparatus appears on a page, but without the bottom apparatus: And here's the case where the bottom apparatus appears on a page, but without the top apparatus: So what I'm wondering is: Given the spacing changes described in beyond-inserts.tex, is it feasible to accomplish this in ConTeXt? Again, I did have this working prior to the most recent ConTeXt release. I'm just not sure (given the engine changes) how to configure this now.
- Automatically include -converted version of images in LaTeX if it existsby monty01 on March 14, 2026 at 1:11 pm
I'm working on a LaTeX document where I have multiple image files, some of which have a -converted version. For example, my files might look like this: a.png b.png b-converted.png c.png c-converted.png d.png I want to include the images in my document using a command like: \includegraphics{a.png} % includes a.png \includegraphics{b.png} % include b-converted.png \includegraphics{c.png} % include c-converted.png \includegraphics{d.png} % includes d.png That is, the logic should be: If basename-converted.ext exists, include that. Otherwise, include the original file: basename.ext. MWE \documentclass{article} \usepackage{graphicx} \begin{document} \includegraphics{a.png} \includegraphics{b-converted.png} \end{document} EDIT: I should work with multiple multiple file extension, like png, jpg, pdf, svg ...
- Drawing distorted circleby Miguel Forteza on March 14, 2026 at 12:14 pm
I was trying to copy this figure (from Elementary Classic Analysis Marsden Hoffman): And I don't know how. I've already seen various posts about a distorted circles where they drawed it randomly and I tried it but the result I get it's not quite like I want. I want like it's a sketch of a set I could have drawn (like the picture), but I get a circle "that has random noise". I know that making figures can be hard (at least for me) so if someone could just give me some indications I'd be really grateful.
- Detecting missing graphics across a large LaTeX repositoryby JeT on March 14, 2026 at 10:14 am
is there a TeX-based solution or is external tooling required? Like many of you (I suppose), I maintain a relatively large LaTeX repository used to produce lecture slides and course material. The project has grown over several years and now contains several hundred .tex files twice as many graphics (.png, .pdf) nested directories shared figures reused across multiple documents Typical usage is simply \documentclass{article} \usepackage{graphicx} \begin{document} \includegraphics{figures/payoff_diagram.png} \end{document} As the project evolves, files are sometimes moved or renamed. When this happens, some paths referenced by \includegraphics become invalid. Maintaining a clean path becomes a nightmare... In practice this leads to two types of issues graphics referenced in .tex files that no longer exist graphics present in the repository but not used anywhere Compiling documents eventually reveals missing files, but in a large repository this becomes slow and inconvenient. So my question is essentially about project-level integrity checks. Is there a way within the TeX ecosystem to automatically audit a repository and detect files referenced by \includegraphics that do not exist graphics present in the repository but never referenced For example Does LaTeX provide tooling to inspect file dependencies across a project Are there packages or TeX utilities designed for this Or is the typical solution to rely on external tooling such as scripts or CI workflows More broadly, with the recent development of automation tools and AI-assisted repository analysis, I am also wondering whether people have started using such approaches to maintain consistency in large LaTeX projects. I would be interested in knowing what workflows people use in practice for this type of problem.
- Any luacode regex patch method to detect greeks letters?by Explorer on March 14, 2026 at 7:57 am
Learning from Mico's answer, I have the following code to add \, between number and letter automaticlly via: s:gsub ( "(%d)(%a)" , "%1\\,%2" ) Here below is the code: \documentclass{article}% lualatex required \usepackage{amsmath,amssymb} \usepackage{luacode} \begin{luacode} function digit_letter_spacer ( s ) return s:gsub ( "(%d)(%a)" , "%1\\,%2" ) end \end{luacode} \newcommand\DigitLetterSpaceOn{\directlua{luatexbase.add_to_callback ( "process_input_buffer" , digit_letter_spacer , "DigitLetterSpace" )}} \newcommand\DigitLetterSpaceOff{\directlua{luatexbase.remove_from_callback ( "process_input_buffer" , "DigitLetterSpace" )}} \AtBeginDocument{\DigitLetterSpaceOn} \begin{document} 23x $23x$ 1a2b3c $E=mc^2$ \[ 23x + 45y - 6z = 114qwq\] \begin{align*} \sum_{i=3n}^{\infty} \frac{5x}{7y} - \sqrt{100w} &\cong 3\mathbb{R} \\ 3x^2+4y^2&=5z^2 \end{align*} While the greek letter is not detected: $5\lambda+6\kappa=7\eta$ \begin{gather} 5\alpha+6\beta=7\gamma \end{gather} \end{document} However, the greek letter is not reconginzed. Any approach to regard Greeks Letter as letters in luacode?
- How to number listings on the right like equations without captions and reference them?by SU3 on March 14, 2026 at 1:32 am
I'm writing a technical document with many short listings, with typically fewer that 5 lines in each listing. Rather than adding captions to these short listings, I would like to number them similarly to how equations are numbered on the right and refer to them by these numbers. I would like for these numbers to appear in line with the first line of each listing. In the example below, I have partially emulated what I want to achieve. There are still two problems that I would like to solve. Can the numbers appear automatically for each instance of the lstlisting environment without typing @!\I@ on the first line of each one? How can I get correct reference numbers? Without \refstepcounter{lstlisting} in the definition of \I, I get [0] for each listing. The lstlisting environment does not appear to increment the lstlisting counter without a caption, which I'm trying to avoid. Even with my hack, \ref gives me the chapter number instead of the listing number; though with the hyperref package, clicking on the reference correctly takes me to the listing. Here is the latex code. \documentclass[11pt,letterpaper]{article} \usepackage[margin=1in]{geometry} \usepackage{indentfirst,xcolor} \usepackage[auto-lang=false]{lipsum} \usepackage{listings} \lstset{ xleftmargin=0.25in, basicstyle={\fontencoding{T1}\ttfamily}, upquote=true, showspaces=false, showstringspaces=false, escapeinside={@!}{@}, } \NewDocumentCommand{\I}{}{% \hfill {\refstepcounter{lstlisting}\color{gray}[\thelstlisting]}% } \setcounter{section}{4} \begin{document} \section{Example} \lipsum[1][1] \lstinline[language=c]{"some text"} is a string in C. \lipsum[1][2] \lstinline[language=Python]{'some text'} is a string in Python. \lipsum[1][3] \begin{lstlisting}[language=c,label={lst:c}] const char* str = "Hello"; @!\I@ \end{lstlisting} \lipsum[2][1-3] \begin{lstlisting}[language=Python,label={lst:python}] str1 = "Hello" @!\I@ str2 = 'World' \end{lstlisting} In Listing \ref{lst:c}, \lipsum[3][1] In Listing \ref{lst:python}, \lipsum[3][2] \end{document}
- How to make \textrightarrow use the Roboto font in LaTeX?by monty01 on March 13, 2026 at 8:09 pm
I am trying to use the Roboto font everywhere in my LaTeX document. I load it using the roboto package: \documentclass{article} \usepackage[sfdefault]{roboto} \begin{document} Some random text A \textrightarrow\ B Some random text \end{document} However, the arrow produced by \textrightarrow does not seem to come from the Roboto font. It looks different from the surrounding text. How can I make \textrightarrow use the Roboto so that it matches the rest of the document?
- Trig label Issues on Graphby Nick B on March 13, 2026 at 1:07 pm
I am trying to recreate this picture from the College Board. I am able to recreate the image with the x-axis labeled in fourths (pi). However, the original shows each label being 1/8 (pi). Each time I try to use specific xtick and xlabel, the spacing is incorrect. Is there an easier way I can do this? Here is my code: \documentclass[12pt]{article} \usepackage{fullpage,parskip,pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, axis equal, clip=false, enlargelimits=false, xlabel={\(x\)}, ylabel={\(y\)}, title={Graph of \(f\)}, grid=major, grid style={black!75}, xmin=-2*pi/3,xmax=13*pi/6, ymin=-5,ymax=4, xtick={-0.75*pi, -0.5*pi, -0.25*pi, 0, 0.25*pi, 0.5*pi, 0.75*pi, pi, 1.25*pi, 1.5*pi, 1.75*pi, 2*pi, 2.25*pi}, xticklabels={, $-\frac{\pi}{2}$, , , , $\frac{\pi}{2}$, , $\pi$, , $\frac{3\pi}{2}$, , $2\pi$, }, ytick={-5, -4, -3, -2, -1, 0, 1, 2, 3, 4}, yticklabels={\(-5\), , \(-3\), , \(-1\), , \(1\), , \(3\)}, title style={ font=\Large, anchor=north, at={(rel axis cs: 0.5,0)}, yshift=-3mm, }, ticklabel style={fill=white}, axis line style={ thick,-{Triangle[length=3mm,width=2mm]},shorten >=-4mm,}, ticklabel style={fill=white, inner sep=1pt, font=\normalsize}, ] \addplot[samples=100,thick,domain=-2.09:6.54]{3*sin(deg(2*x-pi/2))}; \end{axis} \end{tikzpicture} \end{document} Any help would be appreciated. TYA
- Count spaces in LaTeXby Vincent on March 12, 2026 at 7:11 pm
I would like to create a fast/optimized fully expandable function that counts the number of spaces in an argument: \documentclass{article} \begin{document} \countspaces{ A B } % Should return 3 (1 is ok too if leading and trailing spaces are removed) \countspaces{A \mycommand B} % Should return 2 (\mycommand is not expanded) \countspaces{A {a b c} B} % Should return 2 (spaces inside groups are not counted) \end{document} Explicit spaces should be counted too. How to achieve that?
- How to create lines perfectly lie on a circle shape with TikZ?by user516076 on March 12, 2026 at 6:49 am
It's very difficult to make a perfect line that lies on exact circle. This is my full work: \documentclass[tikz,border=1pt]{standalone} \usepackage{tikz} \usepackage{calligra} \usepackage[T1]{fontenc} \begin{document} \begin{tikzpicture}[line width=1pt] \path[use as bounding box] (-5.6,-1.2) rectangle (6.4,7.2); % Circle \draw (2.6,3.0) circle (3.1); % Secant line P-T-U \draw (-5.0,0.1) -- (4.7,5.6); % Chords \draw (2.6,2.3) -- (1.2,1.7); % short chord near S \draw (1.2,1.7) -- (4.0,1.4); % S to V \draw (4.0,1.4) -- (4.7,5.6); % V to U % Angle at S \draw (1.2,1.7) ++(0.55,0) arc[start angle=0,end angle=123,radius=0.55]; % Angle at V \draw (4.0,1.4) ++(-0.55,0) arc[start angle=180,end angle=95,radius=0.55]; % Labels \node[font=\fontsize{34}{34}\selectfont] at (-5.0,-0.4) {$P$}; \node[font=\fontsize{34}{34}\selectfont] at (0.2,2.9) {$T$}; \node[font=\fontsize{34}{34}\selectfont] at (5.2,5.9) {$U$}; \node[font=\fontsize{34}{34}\selectfont] at (4.3,0.4) {$V$}; \node[font=\fontsize{34}{34}\selectfont] at (0.9,0.7) {$S$}; % Angle labels \node[font=\fontsize{28}{28}\selectfont] at (2.0,2.5) {$123^\circ$}; \node[font=\fontsize{28}{28}\selectfont] at (3.6,2.0) {$85^\circ$}; \end{tikzpicture} \end{document} and this is the result: What I want: Please along with full MWE ready to copy paste, could you explain, what the trick is and what to add and where to add, so that I can also learn? T.I.A.
- Why do I get different results of \ifx comparing boxes and macros by having the same content?by MBE on March 11, 2026 at 11:43 pm
\setbox11=\vtop{\hsize=80pt X \hskip1pt eagle \hskip2pt X} \setbox12=\copy11 box 11 and 12 have the same content: \copy11 \copy12 \def\strZ{ \vtop{\hsize=80pt \unvcopy11}} \def\strX{\vtop{\hsize=80pt \unvcopy12}} \vskip\baselineskip strZ and strX have the same content: \strZ \strX \vskip\baselineskip yet, ifx strX strZ YES else NO fi give \hskip110pt\ifx\strX\strZ YES \else NO \fi \vskip\baselineskip \def\strA{\vtop{\hsize=80pt X \hskip1pt eagle \hskip2pt X}} \def\strB{\vtop{\hsize=80pt X \hskip1pt eagle \hskip2pt X}} but strA and strB, both defined with the \vskip\baselineskip same content give \hskip90pt\strA \strB \vskip\baselineskip \hskip280pt\ifx\strA\strB YES \else NO \fi \bye
- Inline formula baseline issues of `a` with TeX Gyre Pagella Math?by Explorer on March 11, 2026 at 3:33 am
Here below is the example code: \documentclass{article} \usepackage{unicode-math} \setmathfont{TeX Gyre Pagella Math} \begin{document} Inline $(\frac{1}{b} , \frac{1}{a})$ \[ (\frac{1}{b} , \frac{1}{a})\] \end{document} Noted that the baseline of a is abnormal when inline, but normal in display. Is that a bug or feature of TeX Gyre Pagella Math? That is also quite confusing for me that why inline and display behave quite different, is not the same a glyph was used? Any hot-fix to change the baseline in inline math for a here? Any tricks(maybe luatex?) are all welcome!