• The water level and the principle of communicating vessels
    by Sebastiano on October 4, 2026 at 7:49 pm

    I would like to create a water level, i.e. a transparent flexible tube filled with water, so that the principle of communicating vessels is clearly illustrated. How can I represent the flexible tube, keeping it along the horizontal surface and making it run up the two vertical sides, so that the configuration is similar to the one shown in the image? Here my 1st MWE: \documentclass{article} \usepackage{tikz} \usepackage{tikzphysics} \begin{document} \begin{tikzpicture}[ line cap=round, line join=round ] \node[ ground, ground width=8.6cm, ground depth=3mm ] (G) at (0,0) {}; \node[ ground, ground width=3.2cm, ground depth=3mm, rotate=90 ] (GL) at (-3.5,1.6) {}; \node[ ground, ground width=3.2cm, ground depth=3mm, rotate=90 ] (GR) at (3.5,1.6) {}; \draw[dashed, thick] (-3.9,2.8) -- (4.2,2.8); \draw[thin] (-3.9,0) -- (-3.7,0); \node[left] at (-3.7,3.1) {\small 100.0}; \draw[thin] (-3.2,0) -- (-3.2,3.1); \draw[thin] (3.8,0) -- (3.8,3.1); \draw[thin] (3.7,0) -- (3.9,0); \node[right] at (3.9,3.1) {\small 100.0}; \draw[thin] (-4.3,0) -- (-3.8,0); \node[left] at (-4.3,0.08) {\small 0.00}; \end{tikzpicture} \end{document} Now with Mathcha I have created the flexible tube, \documentclass{article} \usepackage[margin=0.5in]{geometry} \usepackage{tikz} \usepackage{tikzphysics} \definecolor{water}{RGB}{73,194,221} \pagestyle{empty} \begin{document} \centering \begin{tikzpicture}[x=1cm,y=1cm] \node[ ground, ground width=8.6cm, ground depth=3mm ] (G) at (0,0) {}; \node[ ground, ground width=3.2cm, ground depth=3mm, rotate=90 ] (GL) at (-3.5,1.6) {}; \node[ ground, ground width=3.2cm, ground depth=3mm, rotate=90 ] (GR) at (3.5,1.6) {}; \draw[dashed, thick] (-3.9,2.5) -- (4.2,2.5); \draw[thin] (-3.9,0) -- (-3.7,0); \node[left] at (-3.7,3.1) {\small 100.0}; \draw[thin] (-3.2,0) -- (-3.2,3.1); \draw[thin] (3.8,0) -- (3.8,3.1); \draw[thin] (3.7,0) -- (3.9,0); \node[right] at (3.9,3.1) {\small 100.0}; \draw[thin] (-4.3,0) -- (-3.8,0); \node[left] at (-4.3,0.08) {\small 0.00}; \begin{scope}[shift={(-6cm,-.9cm)}] \draw[gray!70,line width=7pt] (3.48,4.32) .. controls (3.48,3.98) and (3.71,3.58) .. (3.72,3.21) .. controls (3.73,2.85) and (3.50,2.35) .. (3.84,1.74) .. controls (4.10,1.23) and (4.46,1.03) .. (4.97,1.03) .. controls (6.20,1.03) and (7.68,0.99) .. (8.36,1.59) .. controls (8.96,2.09) and (8.90,3.16) .. (8.90,4.23); \draw[gray!20,line width=4.5pt] (3.48,4.32) .. controls (3.48,3.98) and (3.71,3.58) .. (3.72,3.21) .. controls (3.73,2.85) and (3.50,2.35) .. (3.84,1.74) .. controls (4.10,1.23) and (4.46,1.03) .. (4.97,1.03) .. controls (6.20,1.03) and (7.68,0.99) .. (8.36,1.59) .. controls (8.96,2.09) and (8.90,3.16) .. (8.90,4.23); \draw[water,line width=4.5pt] (3.69,3.42) .. controls (3.81,3.02) and (3.49,2.39) .. (3.84,1.74) .. controls (4.10,1.23) and (4.46,1.03) .. (4.97,1.03) .. controls (6.20,1.03) and (7.68,0.99) .. (8.36,1.59) .. controls (8.82,1.98) and (8.92,2.72) .. (8.90,3.42); \end{scope} \end{tikzpicture} \end{document} but the tube is not filled correctly.

  • Defining a point on a plane using Asymptote
    by Fabrice on October 4, 2026 at 12:19 pm

    The idea is to reproduce the figure using the Asymptote software for the first time. The code could likely be improved, given that I determined the points on the plane using the Cartesian equation 25x + 14y - 35 = 0. Is there a better way to define the points on the plane ? import three; import math; size(8cm); defaultpen(fontsize(9pt)); currentprojection=orthographic ( camera=(8,5,4), up=(0,0,1), target=(2,2,2), zoom=1 ); pen style1 = linetype("4 4"); real h = 1; triple A = (1.4*h,0,0), B = (1.4*h,2.5*h,0), C = (0,2.5*h,0), D = (0,0,0), Ep = (1.4*h,0,1.3*h), F = (1.4*h,2.5*h,1.3*h), G = (0,2.5*h,1.3*h), H = (0,0,1.3*h); path3 p = A--C--G--Ep--cycle; draw(surface(p),lightgray+opacity(0.5)); draw(A--B--F--Ep--cycle^^B--F--G--C--cycle^^G--H--Ep); draw(A--D--C^^D--H,dashed); triple I = (0.728,1.2,0.55); triple J = (1.232,0.3,0.3); triple K = (1.036,0.65,0.75); triple S = interp(J,I,1.3); triple Np = interp(J,K,1.3); triple M = shift(Np-J)*S; dot(I);dot(J);dot(K);dot(S);dot(Np);dot(M); draw(interp(J,I,-0.1)--interp(J,I,1.6),style1); draw(interp(J,K,-0.2)--interp(J,K,1.6),style1); draw(S--M,style1); draw(Np--M,style1); draw(J--M,style1); draw(A--C,style1); draw(Ep--G); label("$A$",J, align=NW); label("$B$",I, align=SE); label("$C$",K, align=NW); label("$S$",S, align=SE); label("$N$",Np, align=NW); label("$M$",M, align=SE);

  • Linguistic examples in gb4e: formatting the preamble (NOT the gloss lines)
    by Robert on October 4, 2026 at 9:50 am

    I'm writing a book with a lot of linguistic examples and had to switch from expex to gb4e due to publisher requirements. Most of my examples have three lines, an orthographic representation that is not aligned with the others and two more for interlinear glosses (morphemes and labels). For example: \ea Huŋkhi cektake pho. \\ \gll hun -khiʔ cekt -a -k -e pho \\ MED -MOD say -PST -IPFV -IND.PST[.3sg.S] REP \\ \glt ‘I heard he was saying that.’ \z I know how to format the two interlinear lines using \leteachwordone and \leteachwordtwo. However, my question is about the first line (in the example, Huŋkhi cektake pho.). In expex this would have been called the preamble and I could have modified it using everyglpreamble=\itshape (italicizing this line is my ultimate goal). What is this line called in gb4e and how can I modify it centrally? There is no \leteachwordzero, so I'm at a loss.

  • Custom font sizes like Word Office [duplicate]
    by Sebastiano on October 4, 2026 at 8:42 am

    I am using the extarticle document class because I need larger font sizes than those provided by the standard article class. My document currently starts with: \documentclass[leqno,14pt]{extarticle} As far as I understand, extarticle provides the following font sizes: 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, and 20pt. However, I would like to use intermediate font sizes such as 11.5pt or 11.758653pt, 12.54525pt, 13pt, or 15pt, similar to what is possible in Microsoft Word. Is there a proper way to define or use arbitrary base font sizes to have the same size like Microsoft Word (example: 12.58217582pt)? I am preparing a multiple-choice test with 10 questions and want to typeset it on an A3 page, so being able to fine-tune the font size would be very useful. Related: How to put centered figures in \question{} using TikZ and \includegraphics without mistakes

  • Apparent conflict between \xelatex and \Longrightarrow
    by Leo on October 4, 2026 at 8:34 am

    The command \Longrightarrow gives a broken arrow if I compile using xelatex and a regular (long) arrow if I compile using pdflatex. Here is MWE: \documentclass[11pt,b5paper]{book} \usepackage{amsmath, mathrsfs} %\usepackage[T1]{fontenc} % %\usepackage{fontspec} % %\setmainfont{Tinos} % \usepackage{polyglossia} % \setdefaultlanguage{french} % \setotherlanguages{hebrew, greek} % \newfontfamily\hebrewfont[Script=Hebrew]{Tinos} % \newfontfamily\greekfont[Script=Greek]{Linux Libertine O} % \newfontfamily\greekfontsf[Script=Greek]{Linux Libertine O} \begin{document} $$ A \Longrightarrow B$$ \end{document} This works correctly as it is (with pdflatex). If one includes the commented out (%) code (and compiles with xelatex), the arrow is broken. Is it a known conflict of packages?

  • How to add \tags to multi-line equations in Lyx?
    by Penelope on October 3, 2026 at 11:46 pm

    I am trying to add text using \tag in a multi-line equation in Lyx. Here is how I do it in mathjax for the web. \begin{align} a \alpha \beta + b \beta^2 N^2 & = \beta \\ \\ b (\beta^2 N^2 - \alpha^2) & = \beta  \tag{using (ii)} \\ \\ \beta ( \alpha^2 - \beta^2 N^2) & = \beta \tag{using (iv)}\\ \\ \alpha^2 - \beta^2 N^2 & = 1 \end{align} And the result seems to work: But I can't find any way to do this in the Lyx gui. Perhaps I shouldn't be trying to add tag, and there is a more canonical way to do it? Ultimately I want to express short explainers with each line of a multi-line equation.

  • \autoref does not work for my exercise environment. What should I use?
    by Sourav on October 3, 2026 at 9:51 pm

    I want to link my exercise later in the document such that the text "Exercise #" is (colored and) hyperlinked. For doing the same with the theorem environment, \autoref can be used, but it doesn't work with my exercise environment. How can I make it work ? Here is what I tried : \documentclass{article} \usepackage{amsmath,amsfonts,amssymb,amsthm} \usepackage{hyperref} \hypersetup{ colorlinks=true, filecolor=red, urlcolor=red, linkcolor=red } \newtheorem{theorem}{Theorem} \theoremstyle{definition} \newtheorem{exercise}{Exercise} \begin{document} \begin{theorem} \label{th} A theorem. \end{theorem} \begin{exercise} \label{ex} Some exercise. \end{exercise} See \ref{th} and \ref{ex}. \\ See \autoref{th} and \autoref{ex} \end{document} Output : In particular, I want the second 1 in the second line to be written as Exercise 1, instead of just the number 1.

  • Want an environment titled "Solution of Exercise #"
    by Sourav on October 3, 2026 at 10:26 am

    I am in need of an environment of the following name : Solution of Exercise #, where # is the required exercise number. I know that I can do this in case of a proof : \documentclass{article} \usepackage{amsmath,amsfonts,amssymb,amsthm} \usepackage{hyperref} \hypersetup{ colorlinks=true, filecolor=red, urlcolor=red, linkcolor=red } \newtheorem{theorem}{Theorem} \theoremstyle{definition} \newtheorem{exercise}{Exercise} \theoremstyle{remark} \newtheorem*{solution}{Solution} \begin{document} \begin{theorem} \label{th} Theorem. \end{theorem} Some content in between. \begin{proof}[Proof of \ref{th}] Proof. \end{proof} \end{document} The above gives the following output : How can I do the same for a solution ?

  • Fit side-by-side tables to page width
    by Svend Tveskæg on October 2, 2026 at 6:55 pm

    Introduction This is a follow-up question to List and "complicated" table side-by-side. In Explorer's answer everything looks good, but I forgot to mention the dimensions of the pages in my document, and when I copy-paste the answer into my document, it doesn't fit at all. (That's my own stupid fault for not mentioning this in the first place.) Code \documentclass[ a4paper, 12pt ]{article} \usepackage[ hmargin = 2.4cm, vmargin = 3cm ]{geometry} \usepackage{nicematrix} \usepackage{tabularray} \UseTblrLibrary{tikz} \usepackage{tikz} \usetikzlibrary{calc} \newcommand{\PanelWidth}{65pt} \newcommand{\CellGap}{6pt} \newcommand{\CellPadding}{3pt} \newlength{\CodonLineHeight} \setlength{\CodonLineHeight}{14pt} \newcommand{\GroupLabel}[2]{% \hspace{1pt}% \parbox[c][\dimexpr#1\CodonLineHeight\relax][c]{26pt}{% \raggedright\small\bfseries#2% }% } \newcommand{\ChartCell}[3][\dimexpr4\CodonLineHeight+16pt\relax]{% \parbox[c][\dimexpr#1+\CellGap\relax][c]{\dimexpr#2+\CellGap+\CellPadding*2\relax}{% \centering \parbox[c][#1][c]{#2}{\centering#3}% }% } \newcommand{\CodonLines}[1]{% \begingroup \setlength{\tabcolsep}{0pt}% \begin{tabular}{@{}>{\rule[-.3\CodonLineHeight]{0pt}{\CodonLineHeight}}c@{}}% #1 \end{tabular}% \endgroup } \newcommand{\BraceGroup}[2]{% \hbox{\parbox[c][\dimexpr#1\CodonLineHeight\relax][c]{10pt}{% \centering \raisebox{-2pt}[0pt][0pt]{% \(\nulldelimiterspace=0pt \smash{\left.\vcenter{\hbox{% \rule{0pt}{\dimexpr#1\CodonLineHeight-8pt\relax}% }}\right\}}% \)% }% }\GroupLabel{#1}{#2}}% } \newcommand{\BraceBlank}[2]{% \hbox{% \parbox[c][\dimexpr#1\CodonLineHeight\relax][c]{10pt}{\mbox{}}% \GroupLabel{#1}{#2}% }% } \newcommand{\CodonPanel}[2]{% \ChartCell{\PanelWidth}{% \CodonLines{#1}\hspace{2pt}% \parbox[c][\dimexpr4\CodonLineHeight\relax][c]{37pt}{% \offinterlineskip#2% }% }% } \newcommand{\RowIndex}[1]{{% \renewcommand{\CellPadding}{0pt}% \ChartCell{18pt}{#1}% }} \newcommand{\ColumnIndex}[1]{\ChartCell[18pt]{\PanelWidth}{#1}} \newcommand{\ThirdIndex}[1]{\RowIndex{\CodonLines{#1}}} \begin{document} \noindent X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X {\sffamily \begin{tabular}{c@{\qquad\qquad\qquad}|@{\qquad\qquad}c}% {\sffamily\bfseries Anden base} & {\sffamily\bfseries Betegnelser}\\[-6.5ex] \begingroup \setlength{\tabcolsep}{0pt} \setlength{\extrarowheight}{0pt}\hspace*{30pt}% <-- add left bounding box ... \begin{NiceTabular}{@{}cccccc@{}}[corners, cell-space-limits = 0pt] \CodeBefore \TikzEveryCell{offset = \dimexpr\CellGap/2\relax, fill = teal!60} \begin{tikzpicture} \foreach \r/\rn in {2/3,3/4,4/5,5/6} \foreach \c/\cn in {2/3,3/4,4/5,5/6} \fill[yellow!35] ([xshift = \dimexpr\CellGap/2\relax, yshift = -\dimexpr\CellGap/2\relax]\r-|\c) rectangle ([xshift = -\dimexpr\CellGap/2\relax, yshift = \dimexpr\CellGap/2\relax]\rn-|\cn); \end{tikzpicture} \Body & \ColumnIndex{U} & \ColumnIndex{C} & \ColumnIndex{A} & \ColumnIndex{G} \\ \RowIndex{U} & \CodonPanel{UUU\\UUC\\UUA\\UUG}{\BraceGroup{2}{Phe}\BraceGroup{2}{Leu}} & \CodonPanel{UCU\\UCC\\UCA\\UCG}{\BraceGroup{4}{Ser}} & \CodonPanel{UAU\\UAC\\UAA\\UAG}{\BraceGroup{2}{Tyr}\BraceBlank{1}{\textcolor{red!70!black}{STOP}}\BraceBlank{1}{\textcolor{red!70!black}{STOP}}} & \CodonPanel{UGU\\UGC\\UGA\\UGG}{\BraceGroup{2}{Cys}\BraceBlank{1}{\textcolor{red!70!black}{STOP}}\BraceBlank{1}{Trp}} & \ThirdIndex{U\\C\\A\\G} \\ \RowIndex{C} & \CodonPanel{CUU\\CUC\\CUA\\CUG}{\BraceGroup{4}{Leu}} & \CodonPanel{CCU\\CCC\\CCA\\CCG}{\BraceGroup{4}{Pro}} & \CodonPanel{CAU\\CAC\\CAA\\CAG}{\BraceGroup{2}{His}\BraceGroup{2}{Gln}} & \CodonPanel{CGU\\CGC\\CGA\\CGG}{\BraceGroup{4}{Arg}} & \ThirdIndex{U\\C\\A\\G} \\ \RowIndex{A} & \CodonPanel{AUU\\AUC\\AUA\\AUG}{\BraceGroup{3}{Ile}\BraceBlank{1}{\textcolor{blue!75!black}{Met}}} & \CodonPanel{ACU\\ACC\\ACA\\ACG}{\BraceGroup{4}{Thr}} & \CodonPanel{AAU\\AAC\\AAA\\AAG}{\BraceGroup{2}{Asn}\BraceGroup{2}{Lys}} & \CodonPanel{AGU\\AGC\\AGA\\AGG}{\BraceGroup{2}{Ser}\BraceGroup{2}{Arg}} & \ThirdIndex{U\\C\\A\\G} \\ \RowIndex{G} & \CodonPanel{GUU\\GUC\\GUA\\GUG}{\BraceGroup{4}{Val}} & \CodonPanel{GCU\\GCC\\GCA\\GCG}{\BraceGroup{4}{Ala}} & \CodonPanel{GAU\\GAC\\GAA\\GAG}{\BraceGroup{2}{Asp}\BraceGroup{2}{Glu}} & \CodonPanel{GGU\\GGC\\GGA\\GGG}{\BraceGroup{4}{Gly}} & \ThirdIndex{U\\C\\A\\G} \\ \CodeAfter \TikzEveryCell{offset = \dimexpr\CellGap/2\relax, draw} \begin{tikzpicture} % \node[font = \sffamily\bfseries, anchor = south] % at ([yshift = +2pt]$(1-|2)!0.5!(1-|6)$) {Second Letter}; \node[font = \sffamily\bfseries, rotate = 90, anchor = south] at ([xshift = -2pt]$(2-|1)!0.5!(6-|1)$) {Første base}; \node[font = \sffamily\bfseries, rotate = -90, anchor = south] at ([xshift = +2pt]$(2-|7)!0.5!(6-|7)$) {Tredje base}; \end{tikzpicture} \end{NiceTabular} \endgroup% &% \begin{tabular}{l @{\;=\;} l} \multicolumn{2}{c}{} \\[0.25cm] \textbf{Ala} & Alanine\;(\textbf{A})\\[4pt] \textbf{Arg} & Arginine\;(\textbf{R})\\[4pt] \textbf{Asn} & Asparagine\;(\textbf{N})\\[4pt] \textbf{Asp} & Aspartate\;(\textbf{D})\\[4pt] \textbf{Cys} & Cysteine\;(\textbf{C})\\[4pt] \textbf{GIn} & Glutamine\;(\textbf{Q})\\[4pt] \textbf{Glu} & Glutamate\;(\textbf{E})\\[4pt] \textbf{Gly} & Glycine\;(\textbf{G})\\[4pt] \textbf{His} & Histidine\;(\textbf{H})\\[4pt] \textbf{Ile} & Isoleucine\;(\textbf{I})\\[4pt] \textbf{Leu} & Leucine\;(\textbf{L})\\[4pt] \textbf{Lys} & Lysine\;(\textbf{K})\\[4pt] \textbf{Met} & Methionine\;(\textbf{M})\\[4pt] \textbf{Phe} & Phenylalanine\;(\textbf{F})\\[4pt] \textbf{Pro} & Proline\;(\textbf{P})\\[4pt] \textbf{Ser} & Serine\;(\textbf{S})\\[4pt] \textbf{Thr} & Threonine\;(\textbf{T})\\[4pt] \textbf{Trp} & Tryptophan\;(\textbf{W})\\[4pt] \textbf{Tyr} & Tyrosine\;(\textbf{Y})\\[4pt] \textbf{Val} & Valine\;(\textbf{V})\\[0.8cm] \end{tabular}\\ \end{tabular}} \end{document} Question How do I modify the code in order to make the two side-by-side tables fit on the page?

  • How to test that my package option is not set?
    by gildux on October 2, 2026 at 5:56 pm

    I'm writing a package (that will be called mytest in the MWE) but I'm having a little trouble with the use of one option (the only case presented in the MWE). Well, I have this mytest.sty file: \NeedsTeXFormat{LaTeX2e}[2022/06/02] \ProvidesPackage{mytest}[2026/09/09 v0.0.0 my test] \DeclareKeys[mytest]{% foo.store = \@mytest@foo, foo.usage = load, } \ProcessKeyOptions[mytest] \NewDocumentCommand\myexample{o m }{% foo?, baz \IfNoValueTF{#1}{% use default, set by \IfBlankTF{\@mytest@foo}{nope% package. }{\@mytest@foo% user. } }{#1% use provided… }\space% \emph{#2}% } \endinput Then I use this mytest.tex file: \documentclass{article} \usepackage{mytest} \begin{document} \myexample{yeah}. \end{document} I'd expect the result to be of nope \emph{yeah}. but that's not the case. What am I doing wrong? Note that replacing the \IfBlankTF with \IfNoValueTF gives the same result, so after keys processing \@mytest@foo is neither blank nor null/unset. I'm lost.

  • tex4ebook + offline math SVGs that resize with text size
    by ana on October 2, 2026 at 5:46 pm

    I want to generate epub3 files from .tex files where the mathematics is rendered as offline SVGs, no javascript, and the SVGs automatically resize with the font-size on the ereader. Possible? How? Ereaders now render MathML. Yay. But badly. Boo. SVGs are still visually better. The answers here do not work. They are also a decade old. After many iterations, I figure the SVG must be rendered such that it is scalable and the CSS must make the SVGs scale. So test.tex: \documentclass{article} \begin{document} This is inline: \(\alpha\). This is display: \begin{equation} f(x) = 1 + x \alpha \end{equation} \end{document} math.cfg: \Preamble{xhtml} \Css{img[src$=".svg"] { display: inline-block; max-width: 100%; width: auto; height: auto; }} \begin{document} \EndPreamble build.lua: Make:image("svg$", "dvisvgm --bbox=min --exact-bbox --no-fonts -p ${page} -o ${output} ${source}" ) and command: tex4ebook \ -f epub3 \ -c math.cfg \ -e build.lua \ test.tex \ "svg,pic-m,pic-equation" While this generates the math as SVG, it does not scale with the text. So I'm stumped.

  • List and "complicated" table side-by-side
    by Svend Tveskæg on October 2, 2026 at 3:17 pm

    Introduction I'v been pondering about how to get started with the following table and list side-by-side. Unfortunately, I haven't come up with any useful ideas, so once again I present a "please do (some of) it for me" question. Sorry! 🙁 Question I would like to reproduce the following table and list side-by-side: A few 'corrections': Table: I don't want the light color in the middle of each cell; plain yellow is preferred. List: I would like to left-align both the abbreviations, the equal signs, and the names. Important I hope that I can do the rest of it myself, as long as someone helps me getting started by setting up the "First letter", "Second letter", and "Third letter" labels around the table, the turquoise boxes on the edges of the table, the contents of the top-left yellow cell in the table, the first two rows aligned in the list. Again, I'm sorry for this type of question but I don't know where to start.

  • How to set active characters locally within a command using expl3?
    by modallyFragile on October 2, 2026 at 10:48 am

    How to set active characters locally within a command using expl3? I want to use some characters in special ways inside the argument to a command, which I define with expl3. Let's say I want < to expand to \textlangle. I can set up the active characters successfully outside the command: \documentclass{article} \ExplSyntaxOn \cs_new_protected:Npn \__textlangle: { \textlangle } \char_set_active_eq:nN { `< } \__textlangle: \char_set_catcode_active:N < \ExplSyntaxOff \begin{document} % Desired behaviour, prints 〈foo <foo \end{document} But if I try to do the same thing inside a command, using local asignments, it doesn't work; what's going on? \documentclass{article} \ExplSyntaxOn \NewDocumentCommand{\specialsyntax}{ +m }{ \group_begin: \cs_new_protected:Npn \__textlangle: { \textlangle } \char_set_active_eq:nN { `< } \__textlangle: \char_set_catcode_active:N < #1 \group_end: } \ExplSyntaxOff \begin{document} % Wrong behaviour, prints <foo \specialsyntax{<foo} \end{document} TIA.

  • Content of table cell placed unexpected
    by Svend Tveskæg on October 2, 2026 at 10:14 am

    Introduction This is a follow-up question to Table of amino acids. Code and output % lualatex test.tex \documentclass[ a4paper, 12pt ]{article} \usepackage[ hmargin = 2.4cm, vmargin = 3cm ]{geometry} \usepackage{tabularray} \UseTblrLibrary{tikz} \usepackage{chemfig} \begin{document} \begin{table} \def\penta{1.5}% \def\heksa{1.2}% \centering \scriptsize \def\acidlabels{ { Gly % Glycin , Ala % Alanin , Val % Valin , Leu % Leucin , Ile % Isoleucin }, { Met % Methionin , Phe % Phenylalanin , Pro % Prolin , Asp % Aspartat , Glu % Glutamat }, { Ser % Serin , Thr % Threonin , Cys % Cystein , Tyr % Tyrosin , Asn % Asparagin }, { Gln % Glutamin , Trp % Tryptofan , Lys % Lysin , Arg % Arginin , His % Histidin }% <-- VIGTIG } \begin{tblrtikzabove} \foreach \cols[count = \i] in \acidlabels { \foreach \content[count = \j] in \cols { \node[below right, font = \sffamily\bfseries] at (\i-\j.north west) {\content}; } } \end{tblrtikzabove}% \setchemfig{ fixed length = true, atom sep = 1.3em } \begin{tblr}{ width = \linewidth, colspec = *{5}{X[c]}, hlines, vlines } \chemfig{H_2N-CH(-[6]{\color{red}H})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_3})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H}(-[0,,,,red]{\color{red}\smash[b]{CH_3}})-[6,,,,red]{\color{red}C}|{\color{red}H_3})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H}(-[0,,,,red]{\color{red}\smash[b]{CH_3}})-[6,,,,red]{\color{red}C}|{\color{red}H_3})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H}(-[0,,,,red]{\color{red}\smash[b]{CH_3}})-[6,,,,red]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H_3})-C(=[2]O)-OH} \\ \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}S}-[6,,,,red]{\color{red}C}|{\color{red}H_3})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]*6([6,\heksa,,,red]=[6,,,,red]-=-=-))-C(=[2]O)-OH} & \chemfig{O=[6]C(-[6]*5([6,\penta,,,red]-[,,,,black]HN-[red]---))-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}(=[0,,,,red]{\color{red}O})-[6,,,,red]{\color{red}O}|{\color{red}H})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}(=[0,,,,red]{\color{red}O})-[6,,,,red]{\color{red}O}|{\color{red}H})-C(=[2]O)-OH} \\ \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}O}|{\color{red}H})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H}(-[0,,,,red]{\color{red}OH})-[6,,,,red]{\color{red}C}|{\color{red}H_3})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}S}|{\color{red}H})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]*6([6,\heksa,,,red]=-=(-[:270,,,,red]{\color{red}O}|{\color{red}H})-=-))-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}(=[0,,,,red]{\color{red}O})-[6,,,,red]{\color{red}N}|{\color{red}H_2})-C(=[2]O)-OH} \\ \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}(=[0,,,,red]{\color{red}O})-[6,,,,red]{\color{red}N}|{\color{red}H_2})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]*5([6,\penta,,,red]=-{\color{red}N}(-[:180,0.001,,,draw = none]{\color{red}H})-*6(-=-=-=)--))-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}N}|{\color{red}H_2})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}C}|{\color{red}H_2}-[6,,,,red]{\color{red}N}|{\color{red}H}-[6,,,,red]{\color{red}C}(=[0,,,,red]{\color{red}NH})-[6,,,,red]{\color{red}N}|{\color{red}H_2})-C(=[2]O)-OH} & \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]*5([6,\penta,,,red]-{\color{red}N}=-{\color{red}N}(-[:0,0.001,,,draw = none]{\color{red}H})-=))-C(=[2]O)-OH} \end{tblr} \end{table} \end{document} Question As can be seen in the screenshot above, the contents of the cell in the second row, third column in not at the top of the cell. How do I fix this?

  • Need to fix equal space for all row using tabularray
    by MadyYuvi on October 2, 2026 at 8:12 am

    I tried with: \documentclass[twocolumn]{article} \usepackage{amsmath} \usepackage{array} \usepackage{xcolor} \usepackage{tabularray} \UseTblrLibrary{booktabs,siunitx} \definecolor{tablightcolor}{cmyk}{0.08,0.04,0.01,0}% \definecolor{tabdarkcolor}{cmyk}{0.16,0.07,0.02,0}% \definecolor{tabcolheadcolor}{cmyk}{0.81,0.34,0.07,0}% \SetTblrInner{% rowsep=2pt,% row{1}={l,b},% hborder{1}={belowspace=3.25pt},% hborder{2}={abovespace=2pt,belowspace=6pt},% hborder{Z}={abovespace=6pt},% width=\linewidth,% %%%% row{odd} = {tabdarkcolor},% row{even} = {tablightcolor},% hlines = {1pt,white},% row{1} = {bg=tabcolheadcolor, fg=white,},% }% \NewColumnType{T}{>{\raggedright\hangindent=1em\arraybackslash}X}% \NewColumnType{W}[1]{>{\raggedright\hangindent=1em\arraybackslash}Q[wd=#1]}% \begin{document} \heavyrulewidth=0pt% \lightrulewidth=0pt% \cmidrulewidth=0pt% \let\toprule\relax \let\midrule\relax \begin{table} \caption{Short learning programme.} \begin{tblr}{TW{15pc}} \toprule Sessions & Activity \\ \midrule 1. & The short learning programme was briefly discussed with the participants to help them understand what to expect. They were instructed to write their narratives on teaching approaches they are using with a prompt provided to avoid writing unnecessary information. These narratives were then shared with everyone. \\ 2. & The researchers visited the classrooms of the participants to observe their mathematics lessons following a lesson observation guide. The study mainly focused on teaching approaches, student engagement, and the use of real -- life examples as outlined in the observation guide \\ 3. & This session started with feedback from the participants and researchers. They then learned about HP by reading Gutstein [70] and discussing examples from the book. They were allowed to formulate their own examples to share with each other in preparation for using Hp with their students. \\ 4. & During this session, participants were required to apply the knowledge they gained from the previous session before introducing HP to their students. Researchers revisited the classrooms to observe lessons using the same lesson observation guide. \\ 5. & This time, participants were instructed to give feedback in a form of a narrative focusing on how they perceive HP after making use of it. The researchers make use of these narratives and the noted from the lessons observed as their data. The workshop ended. \\ \bottomrule \end{tblr} \end{table} \end{document}

  • chemfig: distorted ring
    by Svend Tveskæg on October 1, 2026 at 8:30 pm

    Introduction As can most likely be seen from the following code, I'm not an experienced chemfig user. Code and output \documentclass{article} \usepackage{chemfig} \begin{document} \setchemfig{atom sep = 2em} \def\penta{1.5} \chemfig{H_2N-CH(-[6]{\color{red}C}|{\color{red}H_2}-[6,,,,red]*5([6,\penta,,,red]=[6,\penta,,,red]-[6,\penta,,,red]{\color{red}H}|{\color{red}N}-[6,\penta,,,red]*6(-=-=-=)-[6,\penta,,,red]-))-C(=[2]O)-OH} \end{document} Question The ring with HN is distorted (which is do to the addition of the NH, I found out); how do I fix this? Post Scriptum You are more than welcome to simplify the code.

  • How can I highlight in Latex?
    by Giovanna Oliveira Silva on October 1, 2026 at 1:56 pm

    I saw that the packages xcolor and soul have commands for highlighting, and some related commands, but I didn't find how to use them. I mostly found how to put colors in latex, byt I would like to use highlight as I use the bold and italic a lot in my work. Am I on the right path by trying to use these packages or are there better packages for my needs?

  • How to get path info from arg of \usepackage
    by lyl on October 1, 2026 at 12:52 pm

    I build a marco package named 0-path.sty which is loacated in the ‌subdirectory‌ of lib under the root path of my project. In this package, I create a macro named \setpath to designate all directoried for file search. Meanwhile, optional args are given to this package for addtional search pathes. I want to set search pathes when this package is introduced like: \usepackage[pic/, tex/]{../lib/0-path}: With this, the root path, which is used as the start point of file search, would be ../(father directory of lib), and program will find files in these pathes: .././, ../lib/, ../material/, ../pic/, ../tex. \usepackage{lib/0-path}: The default root path is ./ The file test-path.tex in ./test/ introduces this package. But error is given when compiling it: ERROR: Paragraph ended before \path@split was complete. --- TeX said --- <to be read again> \par l.56 What's wrong with my codes? ./lib/0-path.sty: \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{0-path}[2026/09/24 v1.0 ...] \edef\path@currname{\CurrentFilePath/\CurrentFile}%like ../lib/0-path.sty %\show\path@currname \RequirePackage{graphicx} \ExplSyntaxOn \tl_new:N \l_setsearchpath_paths_tl \NewDocumentCommand{\setpath}{s O{} m}{ \clist_set:Nn \l_tmpa_clist {#2} \IfBooleanF{#1} { \clist_put_left:Nn \l_tmpa_clist {./, lib/, material/} } \tl_clear:N \l_setsearchpath_paths_tl \clist_map_inline:Nn \l_tmpa_clist { \tl_put_right:Nx \l_setsearchpath_paths_tl { {#3\tl_trim_spaces:n {##1}} } } \exp_args:NV \graphicspath \l_setsearchpath_paths_tl \cs_set:cpx { input@path } { \exp_not:V \l_setsearchpath_paths_tl } }%\setpath \ExplSyntaxOff %========================================================= % Get opt args of this package \newcommand{\path@options}{} \DeclareOption*{% \ifx\path@options\@empty \xdef\path@options{\CurrentOption}% \else \xdef\path@options{\path@options,\CurrentOption}% \fi } \ProcessOptions\relax %==================================================== % Get root path \def\path@split#1lib/0-path#2\@nil{% \def\path@root{#1}% \ifx\path@root\@empty \def\path@root{./}% \fi } \expandafter\path@split\path@currname\@nil % ========================================================= \setpath[\path@options]{\path@root} %========================================================= \endinput ./test/test-path: \documentclass{article} \usepackage{../lib/0-path} \usepackage{4.1-element}%in the directory of "./lib" \begin{document} \makeatletter \path@currname %print "../lib/0-path.sty" \makeatother \end{document} Apparently, the problem comes from \path@split. How to correct it? PS: I also tried with xstring like this: \RequirePackage{xstring} \IfSubStr{\path@currname}{lib}{ \StrBefore{\path@currname}{lib}[\path@root] \ifx\path@root\@empty \def\path@root{./} \fi }{\def\path@root{./////}}%to see which branch is passed And I get .///// which is apperently a wrong result. Why?

  • lua-unicode-math makes \parbox generate font warnings
    by David Purton on October 1, 2026 at 12:29 pm

    If I select a non-standard font size and then use a \parbox, I get font substitution warnings relating to maths fonts when lua-unicode-math is loaded. This happens even though I do not have any maths in my document. No warnings are produced for normal text (unless I actually include maths, of course). And unicode-math does not do this. Is this expected? Am I doing something wrong? Can I get rid of the warnings? I can use something other than a \parbox, but I have trouble with tagging with boxes… MWE % TeX Program = lualatex \documentclass{article} \usepackage{lua-unicode-math} \usepackage{fontspec} \setmainfont{Noto Serif} \begin{document} \fontsize{16pt}{24pt}\selectfont \parbox{3cm}{Some text} \end{document}

  • Is there any method to invert the even odd rule?
    by D G on October 1, 2026 at 8:37 am

    I want to get rather than Appending (0,0) circle (3.5) is fine but I am wondering whether there are any nicer approaches. odd even rule does not exist too. \documentclass[tikz,border=1cm,12pt]{standalone} \begin{document} \begin{tikzpicture}[ultra thick] \filldraw[fill=red,even odd rule] \foreach \i in {0,0.5,...,3.5}{(0,0) circle (\i)} (0,0) circle (3.5) % just a hack to invert the even odd rule ; \end{tikzpicture} \end{document}

  • What command line do I need to run plain TeX, LaTeX or XeLaTeX with texify?
    by ltcomdata on October 1, 2026 at 4:00 am

    I am working with the latest MiKTeX (26.5) on Windows 11 (and using TeXnicCenter if that makes a difference). The simplest texify call on file.tex is texify.exe file.tex. This runs LaTeX by default on file.tex, producing a DVI file. The MiKTeX manual lists the option --pdf for texify as well. It explains that using this option texify will call miktex-pdftex or miktex-pdflatex to typeset file.tex and produce a pdf file. Well, which one does it call? If it calls pdflatex, how would I create a plain TeX document with texify (and vice-versa)? Finally, from what I read, texify used to have the option --engine= with the possible values of pdftex, xetex, and luatex. I do not see this option in the latest MiKTeX manual for texify. Does this option still work? And can I pass XeLaTeX or LuaLaTeX instead?

  • Latex syntax, LR mode,
    by James Durfee on October 1, 2026 at 12:31 am

    I have very limited experience with latex and coding in general. I am trying to use latex to create a pdf of a proof I have already written out by hand, but I am getting several errors that I do not understand. Any feedback on the code or suggestion on where to start learning would be very appreciated, I have been researching the errors But I can't seem to find a good source for this. thank you for your time. \documentclass[12pt]{article} \usepackage{graphicx} % Required for inserting images \newtheorem{proposition}{proposition} \newtheorem{case}{case} \usepackage{dsfont} \usepackage[OT1]{fontenc} \usepackage{amsthm} \usepackage{amsmath} \title{Equivalence Proof} \author{James Durfee} \date{September 2026} \usepackage{amsthm} \begin{document} \maketitle \begin{proposition} \item Suppose n is an integer. Then the following are equivalent. \begin{enumerate} \item 1. n is odd \item 2. $3n+2$ is odd \item 3. $n^2$ is odd. \end{enumerate} \end{proposition} \begin{proof} Assume n is an odd integer. \begin{case} assume n is odd. By definition $n=2k+1$ where $k \in \mathds{Z}$. \newline thus, \begin{align} n &= 2k + 1 3n + 2 &= 6k + 3 + 2 &= 2(3k+2) + 1 \end{align} where $3k+2$ is a integer by closure. Thus by definition $3n+2$ is odd. \end{case} \begin{case} We will prove the contrapositive. Assume n is even. then by definition $n+2k$ where $k \in \mathds{Z}$. \newline Then, \newline \begin{align} n &= 2k 3n &= 6k 3n+2 &= 6k+2 &= 2(3k+1) \end{align} where by closure $3k+1$ is an integer. So $3n+2$ is even. Thus if $3n+2$ is odd, then $n$ is odd. \end{case} \begin{case} Assume n is odd. Then by definition $n=2k+1$, where $k \in \mathds{Z}$. \newline Then, \begin{align} n &= 2k+1 n^2 &= 4k^2+4k+1 &= 2(2k^2+2k)+1 \end{align} where $2k^2+2k$ is an integer under closure. Then by definition $n^2$ is odd. \end{case} \begin{case} We will prove the contrapositive. Assume n is even. So by definition $n+2k$ where $k \in \mathds{Z}$.\newline then, \begin{align} n &= 2k n^2 &= 4k^2 &= 2(2k^2). \end{align} By closure $2k^2$ is a integer. then by definition $n^2$ is even. Thus if $n^2$ is odd then $n$ is odd. \end{case} Therefore, if n is a integer, then the following are equivalen. 1. $n$ is odd, 2. $3n+2$ is odd, 3. $n^2$ is odd. \end{proof} \end{document}

  • How do we find an alternative to align, similar to \begin{aligned}[t], that allows \allowdisplaybreaks in amsart?
    by Arbuja on September 30, 2026 at 11:00 pm

    I am using Latex Overleaf. Suppose we have the following code: \documentclass[11pt]{amsart} \usepackage{amsmath} \usepackage{enumitem} \usepackage{lipsum} \begin{document} \allowdisplaybreaks \begin{enumerate} \item \lipsum[1-2] \item \lipsum[3-4] \item {\large$\begin{aligned}[t] % Random Equations % & x+y+xyz=10\\ & x+2y+yz=13\\ & 2x+xyz+z=15\\ & 3x+y+yz=7\\ & xy+y^2+zx=100\\ & 7x+yz+xz=1 \end{aligned}$} \end{enumerate} \end{document} Despite the end of the last paragraph (in the code above) being close to the end of page 1, the list of equations in the code does not split into two pages, where the first equation is right next to the item number without spacing. (The other equations are aligned with the first equation.) Question: How do we find an alternative to align (similar to aligned) such that x+y+xyz=10 is right next to its item number with no space in between, the remaining equations are aligned with the first equation right next to the item number, the list of equations are split into two pages? There was an answer to a similar question, but it has spacing between the equations and item number and when applying this to the code above: \documentclass[11pt]{amsart} \usepackage{amsmath} \usepackage{environ, enumitem} \makeatletter \let\olditem\item% Store regular \item macro \newlength{\LHS} \def\processitem#1&#2\relax{% \olditem\hspace*{\LHS}% \llap{$\displaystyle #1{}$}% $\displaystyle{}#2$% } \NewEnviron{mathlist}[1][3em]{% \setlength{\LHS}{#1}% Set Left-Hand Side length \g@addto@macro{\BODY}{\item\relax\item}% Used to delimit the items; last item identified by \item\relax\item \def\item##1\item{% Redefine \item to capture contents \def\optarg{##1}% \expandafter\ifx\optarg\relax\else% Last item not reached \expandafter\processitem##1\relax% Process item \expandafter\item% Recursively continue processing items \fi } \begin{itemize}[label={},labelsep=0pt] \BODY% Process environment (save items) \end{itemize} } \makeatother \usepackage{lipsum} \begin{document} \allowdisplaybreaks \begin{enumerate} \item \lipsum[1-2] \item \lipsum[3-4] \item {\large\begin{mathlist}[1em] % Random Equations % & x+y+xyz=10\\ & x+2y+yz=13\\ & 2x+xyz+z=15\\ & 3x+y+yz=7\\ & xy+y^2+zx=100\\ & 7x+yz+xz=1 \end{mathlist}} \end{enumerate} \end{document} I get errors on latex overleaf. I think this is due to the documentclass being amsart.

  • Change only one word's color in beamer to beamer colors
    by Jim on September 30, 2026 at 6:45 pm

    I want to change the color of only one word within a larger text in beamer. The color I need is one of the default beamer colors, say I want to make this word have the same color as the title of the presentation. Unfortunately, the beamercolorbox environment ends the paragraph and is itself a "paragraph environment" breaking the text. Also, I don't know (and I shouldn't have to) what the exact color of the title is within the particular beamer theme, which means I cannot use \textcolor or \color to manually type in the color. How can one do this? Can I "retrieve" the color somehow or is there a way to stop beamercolorbox from breaking the paragraph?

  • How to use conditional if-then statements in luacas (LuaLaTeX) to filter algebraic solutions based on a sign condition?
    by minthao_2011 on September 30, 2026 at 3:51 pm

    I am using the luacas package in LuaLaTeX to dynamically generate and solve radical equations. In my example, I want to solve the equation: $\sqrt{4x+3} = -x+5$. By squaring both sides, the package successfully finds two roots, $r_{1}$ and $r_{2}$. However, I need to check the extraneous root condition, which is checking if the right-hand side $-x+5 \geq 0$ at those specific root values. Currently, I have to manually hardcode the text conclusions (e.g., deciding which root is valid and writing the final conclusion line by hand). I want to automate this process inside the \begin{CAS} environment using an if-then block or a similar logic feature, so that it automatically filters the valid root and prints the correct concluding text depending on the sign of the evaluated expression. Here is my current working LaTeX code (with manual conclusions): \documentclass{article} \usepackage{luacas} \begin{document} \begin{CAS} vars("x") sq = -x+5 f = topoly((-x + 5)^2) g = topoly(4*x +3) eq = f-g r = ZTable( roots(eq) ) y1 = substitute({[x]=r[1]}, f):simplify() y2 = substitute({[x]=r[2]}, f):simplify() sol1 = substitute({[x]=r[1]}, sq):simplify() sol2 = substitute({[x]=r[2]}, sq):simplify() \end{CAS} Solve the equation: \[\sqrt{\print{g}} = \print{sq}.\] Squaring both sides of the equation, we get: \[\print{f} = \print{g}.\] Simplifying the equation above yields: \[ \print{eq} = 0. \] This equation has two roots: \[r_1 = \print{r[1]}, \quad r_2 = \print{r[2]}.\] We have: \[-r_1 + 5 = \print{sol1} < 0,\] hence $r_1$ is an extraneous root (not a solution). \[-r_2 + 5 = \print{sol2} > 0,\] hence $r_2$ is a valid solution. Therefore, the final solution to the equation is $x = \print{r[2]}.$ \end{document} How can I rewrite this using conditional statements (if ... then ... else) or loop routines inside the \begin{CAS} environment to: Dynamically evaluate if sol1 and sol2 are $\geq 0$ or $<0$ (handling luacas algebraic objects properly when comparing).

  • Table of amino acids
    by Svend Tveskæg on September 30, 2026 at 9:12 am

    The following code is nothing more than a possible very early starting point for a document for amino acids. \DocumentMetadata{tagging = off} \documentclass{article} \usepackage{graphicx} \usepackage{chemfig} \usepackage{tabularray} % maybe use this package for the table \begin{document} \setchemfig{atom sep = 2em} \chemfig{H_2N-CH(-[6,,,,red]{\color{red}H})-C(=[2]O)-OH} \end{document} How do I produce the following table? I would like to also have a table boundary. I hope that I can create all of the 20 drawings myself so I would appreciate some help with the construction of the table and the placement of the name of the amino acid in the top left corner of the first cell.

  • use newline in f:write
    by flawr on September 28, 2026 at 10:08 pm

    I'd like to create a data file using lua in LuaTeX that I can reuse e.g. using pgfplots. But currently I'm stuck printing multiple lines as it seems the "\n" will always get interpreted as a TeX command and not as a newline. How would we correctly do that in this document? \documentclass{article} \usepackage{pgfplots} \usepackage{luacode} \begin{document} \begin{luacode} local f = io.open("data.txt", "w") for x = 0, 10, 0.5 do local y = math.sin(x) f:write(x .. " " .. y .. "\n") end f:close() \end{luacode} \begin{tikzpicture} \begin{axis} \addplot table {data.txt}; \end{axis} \end{tikzpicture} \end{document}

  • How to get pre-numbered theorems in a post-ntheorem world?
    by Gaussler on September 28, 2026 at 5:56 pm

    As mentioned by @UlrikeFischer in this question, ntheorem is currently not compatible with \DocumentMetadata, as the latter now provides theorem environments out of the box which emulate the amsthm interface. Combined with the fact that ntheorem is seemingly unmaintained, it seems I must prepare myself for a post-ntheorem world. But that is quite unfortunate since I prefer pre-numbering my theorem environments. I also like to make the custom argument (if it is provided) completely replace the theorem label. How can I get something similar to this with the new interface? %\DocumentMetadata{pdfstandard=UA-2} % incompatible with ntheorem \documentclass{article} \usepackage{ntheorem} \makeatletter \newtheoremstyle{prenumber}% {\item[\hskip\labelsep \theorem@headerfont ##2\theorem@separator\ ##1\theorem@separator]}% {\item[\hskip\labelsep \theorem@headerfont ##2\theorem@separator\ ##3\theorem@separator]} \newtheoremstyle{prenumberbreak}% {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont ##2\theorem@separator\ ##1\theorem@separator}\hbox{\strut}}}]}% {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont ##2\theorem@separator\ ##3\theorem@separator}\hbox{\strut}}}]} \newtheoremstyle{nonumberplainflex}% for proof environments, see below {\item[\theorem@headerfont\hskip\labelsep ##1\theorem@separator]}% {\item[\theorem@headerfont\hskip \labelsep ##3\theorem@separator]} \newtheoremstyle{nonumberbreakflex}% {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont ##1\theorem@separator}\hbox{\strut}}}]}% {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont ##3\theorem@separator}\hbox{\strut}}}]} \makeatother \theoremseparator{.} \theorembodyfont{\itshape} \theoremstyle{prenumber} \newtheorem{theorem}{Theorem} \theoremstyle{prenumberbreak} \newtheorem{theorembreak}[theorem]{Theorem} \theoremheaderfont{\itshape} \theorembodyfont{\normalfont} \theoremstyle{nonumberplainflex} \newtheorem{proof}{Proof} \theoremstyle{nonumberbreakflex} \newtheorem{proofbreak}{Proof} \begin{document} \begin{theorem} First theorem. \end{theorem} \begin{proof} Proof \end{proof} \begin{theorem}[Pythagorean Theorem] We have~\( c^2 = a^2 + b^2 \). \end{theorem} \begin{proof}[Proof of the Pythagorean Theorem] Draw it! \end{proof} \begin{theorembreak} Theorem environment for use e.g. when the body is a list. \end{theorembreak} \begin{theorembreak}[Fermat's Last Theorem] No non-trivial integral solutions to~\( c^{n} = a^{n} + b^{n} \) for~\( n > 2 \). \end{theorembreak} \begin{proofbreak}[Proof of Fermat's Last Theorem] Too long for this MWE. \end{proofbreak} \end{document}

  • Macro which prints input only if all internal invocations of a second macro are non-blank?
    by modallyFragile on September 28, 2026 at 9:11 am

    I want to define two macros, let's call them \coalesce and \coalescegroup. \coalescegroup is only ever used within \coalesce (names are inspired by the Postgres command). \coalesce prints its input if and only if every instance of \coalescegroup within that input prints something non-blank (where blankness is tested by \tl_if_blank:nTF or a variant). Otherwise it discards its input. \coalescegroup divides its input at every instance of some delimiter -- say \coalesceor, and then prints the first division which is not blank (by the same test). If all are blank, it prints nothing. The motivation is templating in class files. I maintain class files for things like handouts and syllabi, where I often want to do things like print 'my email is ', but only if my email is defined. Usually that would be something like \ifblank{\email}{}{My email is: \email} but with coalesce it can be \coalesce{My email is: \coalescegroup{\email}}, which to me makes much more sense. I also like the idea of setting up active characters for these things within coalesce, so that the last example could be written \coalesce{My email is: <\email>}, but that's a separate issue. How can I do this? Below is a MWE of what I've tried so far. I feel like it's close, but not quite there. My idea was to define \coalesceor to evaluate to itself, then define \coalescegroup to exhaustively expand its input, split it on \coalesceor (which will survive the expansion, because it expands to itself), then map over the result and print the first non-blank element, or the token \__coalesce_stop if they're all blank. Then \coalesce uses the same trick: define \__coalesce_stop to expand to itself, \coalesce then just expands its input, checks to see if the resulting token list includes \__coalesce_stop, and prints it all just if it doesn't. I think the basic idea is probably OK, but I can't get the expl3 details right. \documentclass{article} \ExplSyntaxOn % First attempt at coalescegroup % Define a boolean for 'already done' \bool_new:N \__coalesce_coalescegroup_bool % Processor for arguments \cs_new:Npn \__coalesce_coalescegroup_step #1 { \bool_if:NF \__coalesce_coalescegroup_bool \tl_if_blank:nF #1 % If the group isn't blank, then ... % ... we will (eventually) print this arg. {\tl_set:Nn \tl_tmpa_tl {#1} % ... and set the boolean. \bool_set_true:N \__coalesce_coalescegroup_bool } } % Disjunction token \cs_new:Npn \coalesceor { \exp_not:N \coalesceor } \NewDocumentCommand{\coalescegroup}{ m }{ \bool_set_false:N \__coalesce_coalescegroup_bool % Set the scratch list a to be empty. \tl_set:Nn \tl_tmpa_tl {\__coalesce_stop} \tl_set:Nn \tl_tmpb_tl {\exp_args:Ne {\SplitList{\coalesceor}} { #1 }} \ProcessList \tl_tmpb_tl { \__coalesce_coalescegroup_step } % Print the output \tl_tmpa_tl } % Second attempt \NewDocumentCommand{\newcoalescegroup}{ >{\SplitList{\coalesceor}} m }{ \tl_new:N \coalescegroup_output_tl \tl_set:Nn \coalescegroup_output_tl \__coalesce_stop \tl_set:Nn \tl_tmpa_tl {\exp_args:ne { #1 }} \tl_map_inline:Nn \tl_tmpa_tl { % If the token is non-empty ... \tl_if_blank:nF #1 { % ... then write it to output var \coalescegroup_output_tl \tl_set:Nn \tl_tmpa_tell #1 % ... and break. \tl_map_break: } } % Leave result in the input stream \coalescegroup_output_tl } % Blocker token \cs_new:Npn \__coalesce_stop { \exp_not:N \__coalesce_stop } \NewDocumentCommand{\coalesce}{ m }{ % Print nothing if the blocker cs is found. \exp_args:Ne \tl_if_in:nnTF { #1 } \__coalesce_stop {} { #1 } } \ExplSyntaxOff % Testing values \def\blank{} \def\something{something} \begin{document} \section{First attempt} % Should print nothing, prints `foo bar' \coalesce{foo \coalescegroup{\blank} bar} % Should print nothing (because the second coalesce group fails), % prints `foo something bar baz' \coalesce{foo \coalescegroup{\something} bar \coalescegroup{\blank} baz} % Should print `foo something bar', and does! \coalesce{foo \coalescegroup{\blank \coalesceor \something} bar} % Should print `foo literal bar', and does! \coalesce{foo \coalescegroup{\blank \coalesceor literal} bar}\ \section{Second attempt} % Should print nothing, prints `foo bar' \coalesce{foo \newcoalescegroup{\blank} bar} % These all produce Error: Control sequence \coalescegroup_output_tl % already defined: % % \coalesce{foo \newcoalescegroup{\something} bar \newcoalescegroup{\blank} baz} % \coalesce{foo \newcoalescegroup{\blank \coalesceor \something} bar} % \coalesce{foo \newcoalescegroup{\blank \coalesceor literal} bar} \end{document} TIA.

  • Modern Scientific illustrations: what can we "show off" now that wasn't possible 12 years ago?
    by DJP on September 23, 2026 at 1:05 am

    There is a highly popular post from 2014 showcasing Nice scientific pictures show off but a lot has changed with LaTeX over the last 12 years. What is your best science picture to show off now that wasn't possible 12 years ago? Constraints for each answer: The Picture & Code: Show off a beautiful scientific illustration that utilizes features, packages, or engine capabilities (e.g., LuaLaTeX memory handling, modern pgfplots limits, Luametafun) that remove barriers which routinely stopped typical users from doing this 12 years ago (such as hard memory crashes, lack of default ecosystem support, or prohibitive manual workarounds). The Evolution: You must explicitly explain what technological progress or package developmentover the last decade made this picture possible today. AI usage is allowed, but must be acknowledged per community guidelines.