Week
- Any possible method to handle for-loop more smartly in tikz?by Explorer on January 18, 2026 at 7:31 am
I have the following codes to typeset following: \documentclass[tikz,border=5pt]{standalone} \usetikzlibrary{decorations.pathreplacing} \ExplSyntaxOn \cs_new:Nn \__my_Aterm_tl:n { \tl_set:Nn \l_tmpa_tl { a \sb 1 } \int_step_inline:nnn {2} {#1} { \tl_put_right:Nn \l_tmpa_tl { + a \sb {##1} } } \tl_use:N \l_tmpa_tl } \NewDocumentCommand{\Aterm}{ m }{\__my_Aterm_tl:n{#1}} \ExplSyntaxOff \begin{document} \def\NN{5} \begin{tikzpicture} \foreach \i[evaluate=\i as \nexti using int(\i+1)] in {1,...,\NN}{ \draw (0,{-(\i-1)}) rectangle (\i,-\i); \ifnum\i<\NN\relax \draw[decorate,decoration={brace,amplitude=5pt}] (\i,{-(\i-1)}) -- node[midway,right=3pt] {$b_{\i}-b_{\nexti}$} (\i,-\i); \else \draw[decorate,decoration={brace,amplitude=5pt}] (\i,{-(\i-1)}) -- node[midway,right=3pt] {$b_{\i}$} (\i,-\i); \fi \draw[decorate,decoration={brace,mirror,amplitude=5pt}] (0,{-(\i-1)}) -- node[midway,below=3pt] { % $a_{\i}$ $\Aterm{\i}$ } (\i,{-(\i-1)}); } \end{tikzpicture} \end{document} It works! But the code looks not elegant, for the abrupt \ifnum and expl3-syntex(I have heard from that may cause unexpected result to mix tikz and expl3), is that possible to make good use of evaluate=<variable> as <macro> using <formula> or /remember=<variable> as <macro> (initially <value>)?
- LaTeX macro to generate a centered grid of subfigures from a comma list (no gaps, equal widths, auto sublabels 1,2,3…)by taiwan12 on January 17, 2026 at 7:57 pm
I’m trying to define a LaTeX command that creates a figure containing multiple subfigures from a comma-separated list of image names. I’d like a macro with this interface: \multipleIMG{<images per row>}{<comma-separated list of image files>}{<main label>}{<main caption>} Requirements: Use the full available width (\linewidth). No horizontal and vertical gaps between images. Each row should be centered as a whole (even the last row if it’s not full). All images must have the same width (based on <images per row>). Create sublabels automatically as <main label>_1, <main label>_2, … (1, 2, 3, …). I’m using subcaption. I don’t want visible subcaptions, only labels for referencing (\phantomcaption is fine). Example input: \multipleIMG{3}{location-1,location-2,location-3,location-4,location-5}{fig:first}{Five Figure} This should produce 3 images in the first row, then 2 centered images in the second row, all with equal widths, and labels: fig:first_1, fig:first_2, fig:first_3, fig:first_4, fig:first_5 So that I can reference both the main figure and a subfigure like: \ref{fig:first}, \ref{fig:first_1} Here is an MWE showing the layout I want (hard-coded manually for 5 images). I want to replace this manual code with \multipleIMG. \documentclass{report} \usepackage[demo]{graphicx} \usepackage{subcaption} \usepackage[colorlinks=true]{hyperref} \begin{document} \begin{figure}[htbp] \centering \newlength{\imgw} \setlength{\imgw}{\dimexpr\linewidth/3\relax} \makebox[\linewidth][c]{% \begin{subfigure}{\imgw} \includegraphics[width=\linewidth]{} \phantomcaption \label{fig:first_1} \end{subfigure}% \begin{subfigure}{\imgw} \includegraphics[width=\linewidth]{} \phantomcaption \label{fig:first_2} \end{subfigure}% \begin{subfigure}{\imgw} \includegraphics[width=\linewidth]{} \phantomcaption \label{fig:first_3} \end{subfigure}% } \vspace{-\baselineskip} \makebox[\linewidth][c]{% \begin{subfigure}{\imgw} \includegraphics[width=\linewidth]{} \phantomcaption \label{fig:first_4} \end{subfigure}% \begin{subfigure}{\imgw} \includegraphics[width=\linewidth]{} \phantomcaption \label{fig:first_5} \end{subfigure}% } \caption{Five Figure} \label{fig:first} \end{figure} \ref{fig:first}, \ref{fig:first_1} \end{document}
- Exam Class (Hirschhorn) has different Itemize Spacings for the solution and the solutionbox Environmentsby Simon on January 17, 2026 at 10:32 am
I am working with the "exam" class by Philip Hirschhorn (version 2.704) and I am experiencing some trouble with the spacing of lists, itemize in my case, in solution environments. I see strong differences between the spacing in the "solutionbox" and the other solution environment but I am not proficient enough in lower level Latex or Tex to figure out the reason and potential solutions myself. I could make the lists behave the same by using "enumitem" with \setlist[itemize, 1]{nosep}. As far as I understand, this means that the list settings are actually changing between the different environments. I am interested in an explanation of the underlying mechanisms. Here is a minimum working example for you \documentclass[11pt, answers]{exam} \renewcommand{\solutiontitle}{% \textbf{Solution:}% \par% \noindent% } \begin{document} \textbf{Start of Document} \begin{questions} \question This is a solutionbox environment \begin{solutionbox}{5cm} The solution is either \begin{itemize} \item A \textbf{or} \item B \end{itemize} But it could also be C in a new paragraph. Or D in another new paragraph. \end{solutionbox} \question This is a solution environment \begin{solution} The solution is either \begin{itemize} \item Z \textbf{or} \item Y \end{itemize} But it could also be X in a new paragraph. Or W in another new paragraph. \end{solution} \end{questions} \textbf{End of Document} \end{document} You can see the difference in this screenshot montage it looks like the line spacing is identical but some lengths in the list environment are modified, such as \itemsep or \parsep The behavior of the solution environment is identical with the other solution environments (solutionorbox, etc.) as far as I see. The documentation says that the solutionbox environment is implemented differently from the other environments. I guess that this is part of the reason. Thanks in advance, Simon
- \clearpage causes "not in outer par mode error" on second pass [closed]by RLH on January 17, 2026 at 2:44 am
I have a long document (600+ pages) that uses \clearpage and \afterpage to force some page breaks and figure placement, and breakable tcolorboxes as example environments. I am encountering an intermittent bug in which my calls to \clearpage sometimes result in "not in outer par mode" errors on the second compilation pass, ! LaTeX Error: Not in outer par mode. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.128 \clearpage These errors do not appear to be due to incorrect placement of the command---the document builds correctly on the first, third, and subsequent calls to pdflatex. My best guess is that this is related to shifts in content between compilations (e.g., because a table of contents is inserted). -- The code structure around the error is: \afterpage{ \begin{figure}[p] % figure stuff \end{figure} \clearpage } \clearpage % <---- Error happens here \begin{example}{Example Name}{exampletag} % example stuff \end{example} This code pattern allows me to force the Example tcolorbox to start at the top of a page and have a full-page figure on the page immediately following it, even if the tcolorbox extends beyond a page break: [p] makes sure that no text is placed on the page with the figure \clearpage inside \afterpage{} makes sure that the figure is placed on the page immediately when \afterpage{} triggers, and doesn't get kicked further down the document \clearpage outside of \afterpage{} makes sure that the tcolorbox starts on a fresh page. (As was pointed out in comments, the outside \clearpage negates most of what \afterpage{} provides, and I can in this instance remove the \afterpage{}. I still think something odd is going on with the interaction between \clearpage and the Example tcbtheorem when the pages are moved by the insertion of a table of contents during the second pass compilation.) -- In some cases, I can comment out the \clearpage command, build the document so that the table of contents is created, and then uncomment the \clearpage command to get my desired document formatting. (This is however quite kludgy, and needs to be repeated if I compile from scratch.) It may be relevant that in the instance of this behavior that I'm running into right now, the \clearpage command comes directly before the \begin command for a breakable tcbtheorem environment from tcolorbox. It is quite possible that all such issues have a similar command placement. -- The specific construction of tcolorbox for the example environment is: \renewtcbtheorem[number within=section, number freestyle={\noexpand\thesection.\noexpand\arabic{\tcbcounter}}]{example}{Example}{ detach title, before upper={\tcbtitle.\quad \let\footnotetext=\footaux \let\footnote=\footnoteaux }, enhanced jigsaw, sharp corners, frame hidden, lines before break=4, borderline west={.5pt}{3pt}{black}, right=0pt, toprule=0pt, rightrule=0pt, bottomrule=0pt, leftrule=.5pt, colback=white, colframe=black, breakable=true, opacityback=0, colbacktitle=white, opacitybacktitle=0, coltitle=black, titlerule=0pt, fonttitle=\bfseries, parbox=false, label type=example }{exp} \zcRefTypeSetup{example}{ Name-sg=Example, name-sg=example, Name-pl=Examples, name-pl=examples } -- Any suggestions as to what I should be looking for / known issues? [I know it would be best to provide a minimal working example, but I believe this error is likely a corner case and its being triggered is related to the scale of the document.]
- Hungarian clickable references with manual suffixesby taiwan12 on January 16, 2026 at 9:03 pm
I’m typesetting a document in Hungarian. Hungarian uses case suffixes / postpositions attached to the noun (e.g. ábra, ábrán, ábrára, táblázat, táblázaton), so I need to manually provide the inflected noun in running text. Additionally, I use the chemstyle package and I want scheme environments to behave like figures: same counter as figures (one shared sequence) same caption name (schemes should say “Ábra” in the caption, not “Scheme”) schemes should appear in the List of Figures This scheme/figure integration is already working; I include that code only because it’s part of the real setup. What I’m stuck on is a small helper macro for clickable references that lets me manually supply the Hungarian noun/suffix without duplicating it. \newcommand*\myref[2][ábra]{\hyperref[#2]{\ref*{#2}.~#1}} Desired output (whole text clickable) ábra ábrán táblázat táblázaton Current output (wrong: noun duplicated) ábra 1. ábra ábra 1. ábrán táblázat 1. táblázat táblázat 1. táblázaton Important: If I remove chemstyle (and the scheme-related unification code), then my referencing setup behaves as expected. The duplication issue appears only when chemstyle is loaded / schemes are involved. MWE \documentclass{report} \usepackage[magyar]{babel} \usepackage{geometry} \usepackage[demo]{graphicx} \usepackage{chemstyle} \usepackage[colorlinks]{hyperref} \usepackage[figurewithin=none, tablewithin=none]{caption} \newcommand*\myref[2][ábra]{\hyperref[#2]{\ref*{#2}.~#1}} \makeatletter % scheme and figure counter \let\c@scheme\c@figure \renewcommand{\thescheme}{\thefigure} % schemename caption figurename \renewcommand{\schemename}{\figurename} % scheme into lof \def\ext@scheme{lof} \let\l@scheme\l@figure \makeatother \begin{document} \tableofcontents \chapter{A} \begin{figure}[H] \centering \includegraphics[width=0.5\linewidth]{...} \caption{Caption} \label{figA} \end{figure} \begin{scheme} \centering \includegraphics[width=0.5\linewidth]{...} \caption{Caption} \label{schA} \end{scheme} \begin{figure}[H] \centering \includegraphics[width=0.5\linewidth]{...} \caption{Caption} \label{figB} \end{figure} \begin{table}[H] \centering \begin{tabular}{c|c} & \\ & \end{tabular} \caption{Caption} \label{tabA} \end{table} \myref[ábra]{figA}, \myref[ábra]{schA}, \myref[ábra]{figB}, \myref[táblázat]{tabA} \myref[ábrán]{figA}, \myref[táblázaton]{tabA} \clearpage \phantomsection \addcontentsline{toc}{chapter}{Ábrák jegyzéke} \listoffigures \clearpage \phantomsection \addcontentsline{toc}{chapter}{Táblázatok jegyzéke} \listoftables \end{document} MWE without chemstyle \documentclass{report} \usepackage[magyar]{babel} \usepackage{geometry} \usepackage[demo]{graphicx} \usepackage[colorlinks]{hyperref} \usepackage[figurewithin=none, tablewithin=none]{caption} \newcommand*\myref[2][ábra]{\hyperref[#2]{\ref*{#2}.~#1}} \begin{document} \tableofcontents \chapter{A} \begin{figure}[h] \centering \includegraphics[width=0.5\linewidth]{...} \caption{Caption} \label{figA} \end{figure} \begin{figure}[h] \centering \includegraphics[width=0.5\linewidth]{...} \caption{Caption} \label{figB} \end{figure} \begin{table}[h] \centering \begin{tabular}{c|c} & \\ & \end{tabular} \caption{Caption} \label{tabA} \end{table} \myref[ábra]{figA}, \myref[ábra]{figB}, \myref[táblázat]{tabA} \myref[ábrán]{figA}, \myref[táblázaton]{tabA} \clearpage \phantomsection \addcontentsline{toc}{chapter}{Ábrák jegyzéke} \listoffigures \clearpage \phantomsection \addcontentsline{toc}{chapter}{Táblázatok jegyzéke} \listoftables \end{document}
- Is that possible to just fill=white for text in only one node?by Explorer on January 16, 2026 at 8:07 pm
I have the following code: \documentclass[tikz,border=5pt]{standalone} \begin{document} \ExplSyntaxOn \keys_define:nn {mykey} { foo .tl_set:N = \l_tmpa_tl } \keys_set:nn {mykey} { foo = {O\quad K},%<- } \begin{tikzpicture} \draw[dotted] (0,0) -- (2,0); \node[inner~sep=0pt] at (1,0) {\l_tmpa_tl}; \end{tikzpicture} \begin{tikzpicture} \draw[dotted] (0,0) -- (2,0); \node[fill=white,inner~sep=0pt] at (1,0) {\l_tmpa_tl}; \end{tikzpicture} \ExplSyntaxOff \begin{tikzpicture} \draw[dotted] (0,0) -- (2,0); \node[fill=white,inner sep=0pt] at (.7,0) {O}; \node[fill=white,inner sep=0pt] at (1.3,0) {K}; \end{tikzpicture} \end{document} For the sake of the template settings, the text O\quad K should be put as a token list, as a whole, but I need the third picture's result. Is that possible to just fill=white to just shade the "text area"? Edited: Since cfr commented for the original template case, I would provide more information. Claims: The original package is exam-zh package It depends on xeCJK, so xelatex is must I was not sure that whether it's CJK fonts settings works on every OS. See here. What I want, is to achieve something sealline style as below: It appeared in the leftmargin of exam paper: Now I have the following code: \documentclass{exam-zh} \usepackage{zhlipsum} % \ExplSyntaxOn % % Line 1487 in exam-zh.cls % % https://github.com/xkwxdyy/exam-zh/blob/main/exam-zh.cls#L1487-L1496 % \cs_set:Npn \__examzh_sealline_odd_text_around_line: % { % \node [ anchor = east ] % at ([xshift = -\g__examzh_sealline_odd_text_xshift_dim, yshift = \g__examzh_sealline_odd_text_yshift_dim]current~page~text~area.west) % { % \g__examzh_sealline_odd_text_format_tl % \__examzh_sealline_odd_spread_box:nn { \g__examzh_sealline_odd_text_width_dim } % { \g__examzh_sealline_odd_text_tl } % }; % } % \ExplSyntaxOff \examsetup{ sealline={ show=true, circle-show=false, line-type={loosely-dotted}, text={密封线},%<- the text here is put as `\g__examzh_sealline_odd_text_tl' text-format={\huge\bfseries}, line-thickness={2.5pt}, text-xshift={.375cm} } } \begin{document} \zhlipsum[name=zhufu] \end{document} That is the original case. Noted that 密封线, the l3keys sealline/text is put into \g__examzh_sealline_odd_text_tl ands \g__examzh_sealline_even_text_tl here(why I say as a whole). Which need to be processed by \__examzh_sealline_odd_spread_box:nn here. I want to change the present settings of exam-zh's setting code to the minimal extent.(Of course, I can type text={}, leave it empty, and follow \__examzh_sealline_odd_circle: here to draw multiple \node[fill=white] {密}s) But that change too much the package's setting. So, I simplified it to my origianl post😊.
- Best way to break up long equation to fit the IEEE format (double column)by TastyTurtle on January 16, 2026 at 12:41 pm
I have a very long equation where the fraction line spans the whole equation, which makes it fit poorly in the IEEEtran format! Below is an image of the equation(s) in question, along with the current code I am using. Feel free to think creatively for a solution, I am open to almost anything. \documentclass[a4paper,11pt]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath, amssymb, amsthm} \usepackage{geometry} \usepackage{empheq} \geometry{margin=1in} \begin{document} \begin{empheq}[left=\empheqlbrace]{alignat=2} \label{eq:EOM} &\ddot x_w &= \frac{ \dfrac{k_t}{R_m}V_m - \left(\dfrac{k_e k_t}{R_m}+b_f\right)\left( \frac{\dot{x}_w}{r_w} - \dot\theta_b \right) - r_w m_b l_b\!\left(\ddot\theta_b\cos\theta_b-\dot\theta_b^{2}\sin\theta_b\right) }{ \dfrac{I_w}{r_w}+r_w m_w + r_w m_b }, \\ &\ddot\theta_b &= \frac{ - \dfrac{k_t}{R_m}V_m + \left(\dfrac{k_e k_t}{R_m}+b_f\right)\left( \frac{\dot{x}_w}{r_w} - \dot\theta_b \right) + m_b l_b g \sin\theta_b - m_b l_b \ddot x_w \cos\theta_b }{ I_b + m_b l_b^{2} }. \end{empheq} \end{document} Any help would be awesome Edit: Its my first time working with the IEEEtran format but for this questions, it is just a double-column format. More information can be see here: https://www.overleaf.com/latex/templates/ieee-conference-template/grfzhhncsfqn Furthermore, I have updated the code above so that it's compilabl,e and below is a link to my set of equations in a IEEEtran document: https://www.overleaf.com/read/sqrtfcwfjygr#70ecc2 Edit 2: Three different "solutions" can be see in the image below, its probably best to drop the curly bracket and use ´\multline´: Here is the code to recreate the image above: \documentclass[conference]{IEEEtran} \IEEEoverridecommandlockouts \usepackage{mathtools} \usepackage{empheq} \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} \begin{document} \begin{verbatim} \splitfrac \end{verbatim} \begin{empheq}[left=\empheqlbrace]{align} \ddot{x}_w &= \frac{ \splitdfrac{ \frac{k_t}{R_m}V_m - \left(\frac{k_e k_t}{R_m}+b_f\right)\left( \frac{\dot{x}_w}{r_w} - \dot\theta_b \right) }{ - r_w m_b l_b \left(\ddot\theta_b\cos\theta_b-\dot\theta_b^{2}\sin\theta_b\right) } }{ \frac{I_w}{r_w} + r_w (m_w + m_b) } \label{eq:EOM_xw} \\[1em] \ddot\theta_b &= \frac{ \splitdfrac{ -\frac{k_t}{R_m}V_m + \left(\frac{k_e k_t}{R_m}+b_f\right)\left( \frac{\dot{x}_w}{r_w} - \dot\theta_b \right) }{ + m_b l_b g \sin\theta_b - m_b l_b \ddot{x}_w \cos\theta_b } }{ I_b + m_b l_b^{2} } \label{eq:EOM_thetab} \end{empheq} Fraction and multline\\ \begin{empheq}[left=\empheqlbrace]{align} \begin{split} \ddot x_w &= \frac{1}{\frac{I_w}{r_w} + r_w (m_w + m_b)} \Bigg[ \frac{k_t}{R_m}V_m \\ &\quad - \left(\frac{k_e k_t}{R_m}+b_f\right)\left( \frac{\dot{x}_w}{r_w} - \dot\theta_b \right) \\ &\quad - r_w m_b l_b \left(\ddot\theta_b\cos\theta_b-\dot\theta_b^{2}\sin\theta_b\right) \Bigg] \end{split} \label{eq:EOM_xw} \\[15pt] \begin{split} \ddot\theta_b &= \frac{1}{I_b + m_b l_b^{2}} \Bigg[ -\frac{k_t}{R_m}V_m \\ &\quad + \left(\frac{k_e k_t}{R_m}+b_f\right)\left( \frac{\dot{x}_w}{r_w} - \dot\theta_b \right) \\ &\quad + m_b l_b g \sin\theta_b - m_b l_b \ddot x_w \cos\theta_b \Bigg] \end{split} \label{eq:EOM_thetab} \end{empheq} Negative exponent and multline\\ \begin{multline}\label{eq:EOM_xw} \ddot x_w = \left( \frac{I_w}{r_w} + r_w (m_w + m_b) \right)^{-1} \\ \times \Bigg[ \frac{k_t}{R_m}V_m - \left(\frac{k_e k_t}{R_m}+b_f\right)\left( \frac{\dot{x}_w}{r_w} - \dot\theta_b \right) \\ - r_w m_b l_b \left(\ddot\theta_b\cos\theta_b-\dot\theta_b^{2}\sin\theta_b\right) \Bigg] \end{multline} \end{document}
- Drawing a porous sandwich beamby Tldi You on January 16, 2026 at 9:03 am
Can we reproduce this image in LaTeX Tikz? I try this \documentclass[tikz,border=5pt]{standalone} \usepackage{tikz} \usetikzlibrary{patterns,arrows.meta,decorations.pathmorphing} \begin{document} \begin{tikzpicture}[scale=1] %------------------------------------------------- % Common styles %------------------------------------------------- \tikzset{ block/.style={draw, thick, fill=orange!20}, caps/.style={draw, thick, fill=blue!40}, axis/.style={->, thick}, profile/.style={thick}, } %================================================= % (b) SD %================================================= \begin{scope}[xshift=0cm] % Top and bottom caps \draw[caps] (0,4) rectangle (4,4.5); \draw[caps] (0,0) rectangle (4,0.5); % Main block with layered patterns \draw[block] (0,0.5) rectangle (4,4); % Internal layers \draw[pattern=checkerboard, pattern color=orange!70] (0,2.7) rectangle (4,4); \draw[pattern=crosshatch, pattern color=orange!70] (0,1.6) rectangle (4,2.7); \draw[pattern=grid, pattern color=orange!70] (0,0.5) rectangle (4,1.6); % Axes \draw[axis] (0,2.25) -- (5,2.25) node[above] {$x$}; \draw[axis] (0,2.25) -- (0,5) node[above] {$z$}; % Right profile \draw[domain=0.5:4,smooth,,red,variable=\z] plot ({6-cos(180*\z/((4-0.5)))},{\z}); % Labels \node[right] at (4.1,3.9) {$E_{\max},\,\rho_{\max}$}; \node[right] at (4.1,0.6) {$E_{\max},\,\rho_{\max}$}; \node at (2,-0.6) {(b) SD}; \end{scope} %================================================= % (c) ASD %================================================= \begin{scope}[xshift=8cm] % Top and bottom caps \draw[caps] (0,4) rectangle (4,4.5); \draw[caps] (0,0) rectangle (4,0.5); % Main block \draw[block] (0,0.5) rectangle (4,4); % Gradient-like pattern layers \draw[pattern=checkerboard, pattern color=orange!70] (0,2.5) rectangle (4,4); \draw[pattern=crosshatch dots, pattern color=orange!70] (0,0.5) rectangle (4,2.5); \draw[pattern=checkerboard, pattern color=orange!70] (0,0.5) rectangle (4,1.6); % Axes \draw[axis] (0,2.25) -- (5,2.25) node[above] {$x$}; \draw[axis] (0,0.5) -- (0,5) node[above] {$z$}; % Right profile (asymmetric) % \draw[profile] % (4,4) .. controls (4.8,3.5) and (4.8,1.5) .. (4,0.5); % Labels \node[right] at (4.1,3.9) {$E_{\max},\,\rho_{\max}$}; \node[right] at (4.1,0.6) {$E_{\min},\,\rho_{\min}$}; \node at (2,-0.6) {(c) ASD}; \draw[domain=0.5:4,smooth,,red,variable=\z] plot ({1*(5-cos(45+(180*\z)/(2*(4-0.5)))))},{\z}); \end{scope} \end{tikzpicture} \end{document} Current result:
- datetime2, command \currenttime undefinedby Zarko on January 16, 2026 at 6:43 am
What is wrong with the following MWE: \documentclass{article} \usepackage[showzone=false, showseconds=false]{datetime2} \makeatletter \renewcommand*{\dtm@datetimesep}{\quad} \makeatother \begin{document} \currenttime \end{document} Compilation of above MWE gives error ! Undefined control sequence. l.18 \currenttime
- Hierarchical lists in ConTeXt?by filokalos on January 15, 2026 at 8:08 pm
Can't find the way to write a hierarchical list in ConTeXt. it should be like 1. 1.1 1.1.2 2. 2.1 Only the first numbers of each hierarchy appear. Could anybody help, please?
- In a standalone subpreamble, \newcommand not considered as already defined but acro's \DeclareAcronym considered as already definedby Denis Bitouzé on January 15, 2026 at 2:24 pm
Consider the following MCE (say test.tex): \begin{filecontents*}[overwrite]{subfile} \documentclass{article} \newcommand{\foo}{foo} \begin{document} \foo{} \end{document} \end{filecontents*} \documentclass{article} \usepackage[subpreambles]{standalone} \usepackage{acro} \begin{document} \input{subfile} \end{document} The generated test.sta file: contains \newcommand {\foo }{foo}), is loaded two times (see test.log), but no complaint regarding a command \foo already defined. By contrast, the following MCE (again, say test.tex): \begin{filecontents*}[overwrite]{subfile} \documentclass{article} \DeclareAcronym{cd}{short = CD , long = compact disc} \begin{document} \ac{cd}. \end{document} \end{filecontents*} \documentclass{article} \usepackage[subpreambles]{standalone} \usepackage{acro} \begin{document} \input{subfile} \end{document} fails to compile at the 3rd run because of: (./test.sta ! LaTeX Error: Control sequence \g__acro_cd_pages_seq already defined. Do you understand why?
- Creating a label-reference system for asterisk/obelus symbols in LaTeX equationsby Samuel on January 15, 2026 at 12:16 pm
In LaTeX, I wish to use a sequence of asterisk/obelus symbols ($\dagger$, $\ddagger$, $\ast_1$, $\ast_2$, $\ast_3$, ... ) within my equations and then reference them later in the text. See the following example: \documentclass{article} \usepackage{amsmath} \begin{document} \noindent Here is a minimal example of an equation: \begin{equation} \label{eq:parallelogram_law_like_inequality} \begin{alignedat}{3} \langle a, a-b \rangle &= &\;& \|a\|^2 - \langle a, b \rangle \\ &\leq_{\dagger} & & \|a\|^2 - \langle a, b \rangle + \frac{1}{2}\|b\|^2 \\ &= & & \frac{1}{2}\|a\|^2 + \frac{1}{2}\Big(\|a\|^2 - 2 \langle a, b \rangle + \|b\|^2 \Big)\\ &=_{\ddagger} & & \frac{1}{2} \|a\|^2 + \frac{1}{2}\|a-b\|^2 \end{alignedat} \end{equation} where $\dagger$ follows from blar and $\ddagger$ is an application of the blah blah. \end{document} However rather than manually matching up the different *1, *2, *3, ..., I would like to use some syntax along the lines of \note\label{note:blar} and later \ref{note:blar}. This should automatically enumerate the notes in the order they appear and create a hyperref target and link similarly to how equation/figure/table references work. What is the neatest way to achieve this? Thanks!
- Primes in Latexby legogubben on January 15, 2026 at 10:18 am
I want to create a command \isthisprime{<number>} where it decides whether <number> is or is not prime, and if it is, it also returns the order of the prime (eg, 2 is the first, 3 is the second, and so on). Here is my attempt at a code (excuse my choice of naming the counters): \documentclass{article} \usepackage{amsmath} \usepackage{enumitem} \usepackage{lipsum,blindtext} \newcount\div \newcount\divs \newcount\somnum \newcount\yes \newcount\yess \newcount\numberofprimes \newcommand{\isthisprime}[1]{% %Decide if #1 is prime \div=2 \yes=0 \ifnum#1<2 \yes=1 \fi \loop \ifnum\div<#1 \ifnum#1=\numexpr(#1/\div)*\div\relax \yes=1 \fi \advance\div by 1 \repeat \numberofprimes=0 \somnum=2 \yess=0 \divs=2 %Checking every number less than or equal to #1 \ifnum\yes=0 \loop \ifnum\somnum<\numexpr#1+1\relax \loop%checking if somnum is prime \ifnum\divs<\somnum \ifnum\somnum=\numexpr(\somnum/\divs)*\divs\relax \yess=1 \fi \advance\divs by 1 \repeat \ifnum\yess=0 \advance\numberofprimes by 1 \fi \yess=0\divs=2\advance\somnum by 1 \repeat \fi \ifnum\yes=0 #1 is a prime with index~\the\numberofprimes. \else #1 is not a prime. \fi } \begin{document} \isthisprime{101}\newline \isthisprime{102} \end{document} The idea: the first part of the code decides whether or not <number> is a prime; if it is we set the counter \yes=1, otherwise it remains equal to 0. So if \yes=1 we check every number less than or equal to <number> to see if it is prime or not. At every occurrence of prime, we increase the counter \numberof primes. Hence \numberofprimes will determine the order of <number>, if it prime that is. The part where it decides whether or not the input is prime or not is fine. However, it cannot find its order. It just says that the order is 1 if the input is prime. It cannot see what is wrong with my code, so I would appreciate any advice! Thank you in advance.
- Is there a tool that translates LaTeX written with user-defined commands into standard LaTeX?by Steven Thomas Hatton on January 15, 2026 at 7:23 am
I have a (far from ideal) collection of macros that I \include in the preambles of my documents. It's very useful in giving my documents uniform semantic representation. For example, contravariant vector component functions all have a common appearance which I control globally. The down-side to this is that when I want to post an except to math.stackexchange.com, for example, I have to manually convert all of my LaTeX code into standard LaTeX which is independent of my preamble. Obviously the Tex-engine (e.g., lualatex) converts my macros into a form that TeX understands which is equivalent to standard LaTeX. Is there a tool that will take my customized LaTeX documents and convert them into standard LaTeX? Here's an example. (Please don't question the sanity of my notation. I have professionals for that.) \documentclass[a4paper,10pt]{article} \usepackage{amsmath} \newcommand{\CONST}[1]{\mathrm{#1}} \newcommand{\dd}{\CONST{d}} % differential d \newcommand{\DD}[2]{\frac{\dd#1}{\dd\CONST{#2}}} % derivative \newcommand{\PD}[2]{\frac{\partial #1}{\partial\CONST{#2}}} % partial derivative \begin{document} Written using my macros: \begin{align*} \dd f & = \PD{f}{x}\dd x + \PD{f}{y}\dd y.\\ \DD{f}{t} & = \PD{f}{x}\DD{x}{t}+\PD{f}{y}\DD{y}{t} \end{align*} What I want the tool to output: \begin{align*} \mathrm{d} f & = \frac{\partial f}{\partial \mathrm{x}} \mathrm{d} x + \frac{\partial f}{\partial \mathrm{y}} \mathrm{d} y.\\ \frac{\mathrm{d} f}{\mathrm{d}\mathrm{t}} & = \frac{\partial f}{\partial \mathrm{x}}\frac{\mathrm{d}x}{\mathrm{d}\mathrm{t}} +\frac{\partial f}{\partial \mathrm{y}}\frac{\mathrm{d}y}{\mathrm{d}\mathrm{t}} \end{align*} \end{document}
- Help me draw a labor supply diagramby henry on January 15, 2026 at 6:26 am
I'm trying to draw these two diagram in a slide but I cannot do it. Anyone can help me please. This is my previous code: \begin{frame}{Backward-bending Supply Curve} \vspace{0.1cm} \begin{columns}[T] \column{0.55\textwidth} \centering \resizebox{1\textwidth}{!}{% \begin{tikzpicture} \begin{axis}[ axis lines = left, xmin=0, xmax=125, ymin=0, ymax=3200, xtick={70, 80, 90, 110}, ytick=\empty, xlabel={leisure ($L$)}, ylabel={consumption(\textdollar)}, ylabel style={rotate=90, at={(axis description cs:0.03,1)}, anchor=south}, xlabel style={at={(axis description cs:1,0)}, anchor=north west}, clip=false] \coordinate (E) at (axis cs: 110, 0); \filldraw[black] (E) circle (2.5pt) node[right, font=\footnotesize] {$E$}; \node[below, font=\scriptsize] at (axis cs: 110, -50) {}; \coordinate (P1) at (axis cs: 90, 260); \coordinate (P2) at (axis cs: 70, 800); \coordinate (P3) at (axis cs: 80, 750); \draw[lineBlue, thick] (axis cs: 0, 1430) -- (E) node[pos=0.15, left, font=\tiny, black] {$w=13$}; \draw[lineBlue, thick] (axis cs: 0, 2200) -- (E) node[pos=0.15, left, font=\tiny, black] {$w=20$}; \draw[lineBlue, thick] (axis cs: 0, 2750) -- (E) node[pos=0.15, right, font=\tiny, black] {$w=25$}; \draw[curveBlack, thick] (axis cs: 60, 800) to[out=-75, in=160] (P1) to[out=-20, in=170] (axis cs: 115, 120) node[right, font=\tiny] {$U_1$}; \draw[curveBlack, thick] (axis cs: 45, 1600) to[out=-80, in=145] (P2) to[out=-35, in=165] (axis cs: 105, 300) node[right, font=\tiny] {$U_2$}; \draw[curveBlack, thick] (axis cs: 60, 1600) to[out=-85, in=135] (P3) to[out=-45, in=170] (axis cs: 105, 200) node[right, font=\tiny] {$U_3$}; \draw[dashed, thin, gray] (P1) -- (axis cs: 90, 0); \draw[dashed, thin, gray] (P2) -- (axis cs: 70, 0); \draw[dashed, thin, gray] (P3) -- (axis cs: 80, 0); \filldraw[dotRed] (P1) circle (2pt); \filldraw[dotRed] (P2) circle (2pt); \filldraw[dotRed] (P3) circle (2pt); \draw[dotted, thick, black] (E) .. controls (100,100) .. (P1) .. controls (80, 500) .. (P3) -- (P2) node[above left, font=\tiny] {Expansion Path}; \end{axis} \end{tikzpicture} } \vspace{0.1cm} \footnotesize \textbf{(a) Optimal bundles} \column{0.45\textwidth} \centering \resizebox{1\textwidth}{!}{% \begin{tikzpicture} \begin{axis}[ axis lines = left, xmin=0, xmax=55, ymin=0, ymax=32, xtick={0, 20, 30, 40}, ytick={10, 13, 20, 25}, xlabel={Giờ làm việc ($H$)}, ylabel={Mức lương ($w$)}, ylabel style={rotate=90, at={(axis description cs:0.05,1)}, anchor=south}, xlabel style={at={(axis description cs:1,0)}, anchor=north west}, grid=major, grid style={dotted, gray!50}, clip=false ] \coordinate (S1) at (axis cs: 20, 13); \coordinate (S2) at (axis cs: 40, 20); \coordinate (S3) at (axis cs: 30, 25); \coordinate (S0) at (axis cs: 0, 10); \draw[lineBlue, very thick] (S0) to[out=10, in=-120] (S1) to[out=60, in=-90] (S2) % Đoạn dốc lên to[out=90, in=-20] (S3) % Đoạn vòng ngược to[out=160, in=-60] (axis cs: 25, 30); \filldraw[dotRed] (S1) circle (2.5pt); \filldraw[dotRed] (S2) circle (2.5pt); \filldraw[dotRed] (S3) circle (2.5pt); \filldraw[black] (S0) circle (2pt); \node[right, font=\scriptsize, color=lineBlue] at (axis cs: 30, 28) {Labor Supply}; \end{axis} \end{tikzpicture} } \vspace{0.1cm} \footnotesize \textbf{(b) Labor supply} \end{columns} \end{frame}
- No headings in index for words starting with umlauts (pdflatex)by Hakan on January 14, 2026 at 7:44 pm
When I turn on headings for entries in index, I get the following error: ! LaTeX Error: Invalid UTF-8 byte sequence (�\check@icr). This is a minimal tex file: \documentclass{scrbook} \usepackage{splitidx} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[ngerman]{babel} \makeindex \newindex[Index of Fruits]{fru} \begin{document} \sindex[fru]{Äpfel} \sindex[fru]{üzüm} \printindex[fru][Index of Fruits] \end{document} This is a minimal style file: headings_flag 1 heading_prefix "{\\textbf{" heading_suffix "}}\\nopagebreak\n" If I set headings_flag to 0 in the style file, I get no error messages. But the entries in index don't get headings in this case. In order to reproduce the same error, follow these steps: pdflatex file.tex splitindex file.idx -- -s style.ist pdflatex file.tex There is a similar question, which has no accepted answer. Index category for umlauts
- How to underline a tagged parbox?by Teepeemm on January 14, 2026 at 7:20 pm
I have answer blanks on an exam, and then I like to fill them in with the answers. Because the answer may need to be a displayed equation, I put it all in a parbox that gets underlined. This all works fine, until I try to enable tagging, at which point the displayed equation causes "Package tagpdf Error: The number of automatic begin and end text para hooks differ!" Is there a tagging friendly way to underline a parbox? \DocumentMetadata{lang=en-US,tagging=on} \documentclass{article} \begin{document} 1. \underline{\parbox{1in}{~}}\par 2. \underline{\parbox{1in}{\makebox[1in]{}}}\par 3. \underline{\parbox{1in}{okay}}\par 4. \underline{\parbox{1in}{$okay$}}\par 5. \underline{\parbox{1in}{\[not~okay\]}} \end{document}
- Strange behavior of a counter using siunitx, mathtools and array (2025)by Watson on January 14, 2026 at 7:17 pm
Consider the following piece of code (MWE): \documentclass{article} \usepackage{siunitx} \usepackage{mathtools} \newcounter{A} \setcounter{A}{1} \begin{document} $\begin{array}{c} \text{\arabic{A}:} \text{\arabic{A}\stepcounter{A}:} \text{\arabic{A}\stepcounter{A}:} \text{\arabic{A}\stepcounter{A}:} \text{\arabic{A}\stepcounter{A}:} \end{array}$ \end{document} Compiling with the 2025 TeX distribution, it produces the following output: 1:2:6:10:14 which is very unexpected, since I just increment the counter A once by line. On the other hand: Compiling with the 2024 or 2023 TeX distribution yields the expected output 1:2:3:4:5 The expected output is also obtained if we swap the two line \usepackage{siunitx} and \usepackage{mathtools}. Can anyone explain this strange behavior to me?
- Making geometric frieze (pattern) with tikzby Erwan on January 14, 2026 at 9:11 am
i'm trying to do some geometric frieze with tikz. The last goal is to do a command to draw one of the 7 possible frieze (see wikipedia). But, first, i just do 1 frieze. Results: My code: \documentclass[tikz]{standalone} \begin{document} \newcommand{\footstep}[4]{ \begin{scope}[ xshift=#3cm, %for translation yshift=#4cm, %for translation xscale=#1, %for reflexion yscale=#2 %for reflexion ] \draw (1, 3) -- (1, 0); \draw (1, 0) -- (7, 0); \draw (6, 3) -- (7, 0); \draw (6, 3) -- (5, 0); \draw (5, 0) -- (4, 2); \draw (4, 2) -- (2, 0); \draw (2, 0) -- (1, 3); \end{scope} } \begin{tikzpicture}[rounded corners=1pt, very thick, scale=.75] \draw[help lines] (0,-1) grid (22,5); \footstep{1}{1}{0}{0} \footstep{1}{-1}{7}{3} \end{tikzpicture} \end{document} but i have to find the parameters by myself. I'd like something automatic. Something like : xshift = "scope width" yshift = "scope height" Thanks
- Unable to enumerate in tagged lualatexby Miloop on January 14, 2026 at 7:12 am
I am trying to make an inline list using enumerate*, but it isn't working when trying to make a tagged document. I want the output to look like this: , but I am getting lonely item errors. Here is my minimal code that generates the error: \DocumentMetadata{lang=en-UK, tagging=on, pdfstandard=UA-2} \documentclass[a4paper,12pt,oneside]{book} \usepackage[inline]{enumitem} \begin{document} Therefore such ideas are expressed as: \begin{enumerate*}[label=(\roman*)] \item Suggestions \item Compulsions \item Delusions \item Pertrusions \item Overwhelming sense of righteousness \item Own by themselves where every entity is largely linked to another for its own survival. \end{enumerate*} \end{document} and here is the first bit of the the error in the .log: ! LaTeX Error: Lonely \item--perhaps a missing list environment. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.11 \item S uggestions Try typing <return> to proceed. If that doesn't work, type X <return> to quit.
- Acro package: Use long form for pdfcommentby miile7 on January 13, 2026 at 10:05 am
I am using the (awesome) acro package to manage my acronyms. Therefore, I want acronyms to be displayed in the pdf when hovering over them. acro supports this out of the box by using the pdfcomment package and the pdfcomments/use=true option. I always want to display the long form of the acronym, which is (in my case) always just text. So currently I'm using the following (for MWE see below): \DeclareAcronym{AI}{ short=AI, long=artificial intelligence, pdfcomment=artificial intelligence, } While this creates exactly the output I'm looking for (and I'll continue to use it, if not otherwise possible), it feels weird to insert the same text twice. As acro has served with perfect solutions to all my problems until now, I'm wondering whether there is a more elegant way to just use the long form for the pdf comments. Thank you in advance. Minimal Working Example (MWE): \documentclass{article} \usepackage{acro} \usepackage{pdfcomment} \acsetup{ pdfcomments/use=true, } \DeclareAcronym{AI}{ short=AI, long=artificial intelligence, pdfcomment=artificial intelligence, } \begin{document} Currently, the big thing is \ac{AI}. \end{document} Results in the following intended behavior:
- Put a text in the middle of a path move operation in Tikzby Harald on January 12, 2026 at 4:24 pm
I know how to use \draw (0,0) -- node[below]{X} (10,0); to put the text X in the middle below the line between the coordinates. What I would like to have is the very same, but without drawing the line, yet the following does not work (somewhat to my surprise :-/) \draw (0,0) node[below]{X} (10,0); I figured out a way involving node at ($ ...!.5!... $) yet \draw would sometimes be a bit more natural and I would in particular like to understand why it does not work, as I seem to miss some fundamental knowledge here.
- In ltx-talk make text body not vertically centeredby Jim Hefferon on January 12, 2026 at 3:44 pm
In ltx-talk the default is for body text to be vertically centered. How to instead make it display always starting from the page top? Vertical centering makes the text jump around when I use the \only<..>{} command. That is, how to achieve what in Beamer I get with \beamer@centeredfalse? Here is an MWE. Between slides 1 and 2 the first paragraph jumps up. \DocumentMetadata{tagging = on} \documentclass{ltx-talk} \usepackage{blindtext} \begin{document} \begin{frame} \frametitle{Frame title} \blindtext \only<2>\blindtext \end{frame} \end{document}
- Can no longer change BoldFont with New Computer Modernby mbert on January 12, 2026 at 3:13 pm
Until a recent update, the following example used New Computer Modern book weight in the first paragraph and Latin Modern demibold in the second paragraph (confirmed with an older texlive in Overleaf). After the update, the BoldFont setting no longer seems to work and New Computer Modern bold is used. \documentclass{article} \usepackage{fontspec} \usepackage{kantlipsum} \setmainfont{NewCM10-Book.otf}[ BoldFont=lmromandemi10-regular.otf, ] \begin{document} \kant[1][1-2] \bfseries \kant[1][1-2] \end{document} I know there was some recent discussion around NewCM defaulting to Harf mode and not being able to override this due to the provided .fontspec files. Did something change so that setting BoldFont is no longer possible? Note that if NewCM10-Book.otf is changed to another font, say TeX Gyre Pagella, then the example works as expected.
- breakage regarding thmtools and mdframedby DavidIsAqwerty on January 12, 2026 at 2:12 pm
So basically this time I was using overleaf again and came across this error: When I do \documentclass[11pt]{scrartcl} \usepackage[dvipsnames,svgnames]{xcolor} \usepackage[framemethod=TikZ]{mdframed} \usepackage{amsmath,amssymb,amsthm} \usepackage{thmtools} \mdfdefinestyle{mdgreenbox}{linecolor=ForestGreen,backgroundcolor=ForestGreen!5, linewidth=2pt,rightline=false,leftline=true,topline=false,bottomline=false,} \declaretheoremstyle[headfont=\bfseries\sffamily\color{ForestGreen!70!black}, mdframed={style=mdgreenbox},headpunct={.},]{thmgreenbox} \mdfdefinestyle{mdblackbox}{linecolor=black,backgroundcolor=RedViolet!5!gray!5, linewidth=3pt,rightline=false,leftline=true,topline=false,bottomline=false,} \declaretheoremstyle[mdframed={style=mdblackbox}]{thmblackbox} \declaretheorem[style=thmblackbox,name=Blah,numbered=no]{bla} \declaretheorem[style=thmgreenbox,name=Blahblah,numbered=no]{blah} \begin{document} \begin{bla} \begin{blah} Blah blah blah blah blah \end{blah} \begin{proof} blah blah blah blah blah \end{proof} \begin{itemize} \item Blah blah blah blah blah \item Blah blah blah blah blah \end{itemize} \end{bla} \end{document} It breaks and gives me which is just weird. The “Blah.” should be at the very front of the black box while the “Proof” should be right below the green. Also there is no bullet point for the first item in itemize. Surprisingly, If I remove the Blahblah section (the green box) everything comes out normally! (The blahs are edited from some content in my actual file)
- Cyrillic script letter el with tailby moorooduc on January 11, 2026 at 11:19 pm
I am trying to typeset a text in the Khanty language, whose orthography uses the Cyrillic script. I know how to make Cyrillic script work in the book project, but Khanty has the letter Ӆ ӆ (that's a Cyrillic lower case "L" with a tail: https://en.wikipedia.org/wiki/El_with_tail). I don't find a way to typeset this correctly. Does anyone have advice?
- Why is my pgffor loop not iterating as expected? \foreach \i[parse=true] in {0,pi/18,...,2*pi-pi/18} {works \i\\}by Jasper on January 11, 2026 at 10:47 pm
Why is my pgffor loop not iterating as expected? \documentclass{article} \usepackage{pgffor} \begin{document} \foreach \i[parse=true] in {0,pi/18,...,2*pi-pi/18} {works \i\\} \end{document} It only prints the first two elements of the sequence, but not the rest. It does however work when I evaluate the numbers first: \documentclass{article} \usepackage{pgffor} \usepackage{pgfmath} \begin{document} \pgfmathsetmacro{\a}{pi/18} \pgfmathsetmacro{\b}{2*pi-\a} \foreach \i[parse=true] in {0,\a,...,\b} {works \i\\} \end{document} I would expect parse = true to do this for me. Am I mistaken?
- tikz: using the pos key to place nodes along a plotby Jasper on January 11, 2026 at 7:39 pm
In this tikz MWE, why is the node placement not even close to pos=0.7 on a plotted curve? \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \draw[ domain = 0:2, samples = 100, variable = \y ] plot (\y*\y,\y) node[pos = 0.7, above left] {\(x=y^2\)} ; \end{tikzpicture} \end{document}
- Problem with \ifxby user209882 on January 11, 2026 at 6:32 pm
\def\drawDSID#1#2{ \def\trP{#2}\def\rpT{R}\def\trV{\ifx{\trP}{\rpT}3\else2\fi} \trV} The result is always 2, irrespective of #2, eg \drawDSID{(0,-7)}{R};
- Creating a CircuiTikz custom voltage source component/style with a plus sign for polarityby MatG on January 11, 2026 at 6:24 pm
In certain contexts (italian schools) an ideal DC voltage source is represented by the symbol in this circuit: \documentclass{standalone} \usepackage{circuitikz} \begin{document} \begin{circuitikz} \draw (0,0) to[V,a^=V1,name=VS] (0,4); \node[above left,inner sep=1pt] at (VS.e) {$+$}; \draw (0,0) to[V,a=V2,name=VS] (4,0); \node[above right,inner sep=1pt] at (VS.e) {$+$}; \draw (4,4) to[V,a=V3,name=VS] (0,4); \node[below left,inner sep=1pt] at (VS.e) {$+$}; \draw (4,4) to[V,a^=V4,name=VS] (4,0); \node[below right,inner sep=1pt] at (VS.e) {$+$}; \end{circuitikz} \end{document} This is the symbol I want. Unfortunately, drawing circuits like this is rather cumbersome, so I’m wondering whether it would be possible to define a CircuiTikz style or a custom component that produces the symbol in a more natural way. I’m not a TikZ expert, and I struggle with the part of the documentation that explains how to create new components. I’m aware of existing questions such as: Adding a plus sign in a circuit diagram Including +/- signs to battery in Circuitikz But the answers there didn't help me. I also had no luck with AI tools, so I’m hoping someone with more experience in CircuiTikz and TikZ can offer some guidance.