• Is there a "hook" to expand a macro after the end of a path in TikZ?
    by Rmano on January 18, 2026 at 7:33 pm

    I am adding a new feature to circuitikz to simplify the usage of "user-defined" voltages (and currents and "flow"s). The question is not specific to circuitikz, although the MWE is — sorry for the complication. If I manage a smaller MWE I'll post here. The basic question is: when a TikZ \path command is processed (and a \draw, etc., which are basically the same), is it possible to add a hook to be expanded at the end of it? I mean, after the final ; is found. In the following MWE, I would like to add some code to the addcall key so that I do not need to add the final \DoAdvVoltage. Ideally, the macro should be called after each path is finished, but calling it before of the end of the environment wold be acceptable. The solution should be engine-independent (well, it should work in the engines supported by TikZ). \documentclass[12pt]{article} \usepackage[T1]{fontenc} \usepackage[RPvoltages]{circuitikz} % just an example \ctikzset{voltage=raised, !v sym/.style={no v symbols}} \newcommand{\placesigns}[2]{% place the +- signs at a fixed distance \path (#1voltage.center) ++(-\ctikzgetdirection{#1}:0.5cm) node[]{$+$}; \path (#1voltage.center) ++(180-\ctikzgetdirection{#1}:0.5cm) node[]{$-$}; } % add a command queue to circuitikz \makeatletter \gdef\local@voltages{} \def\addcommand#1#2{%add to \commands the macro \#1{nodename}{#2} \begingroup \edef\@@name{\ctikzvalof{bipole/name}} \edef\@@temp{% \noexpand\pgfutil@g@addto@macro\noexpand\local@voltages{% \expandafter\noexpand\csname #1\endcsname {\@@name}{#2}% }% }% \@@temp \endgroup } \def\DoAdvVoltages{\local@voltages\relax\gdef\local@voltages{}} \makeatother % This works, but just for LaTeX (or not?) % Moreover, I'd like to add this from the addcall keys, so that % I don't call it for *every* tikzpicture! % \AddToHook{env/tikzpicture/end}{\DoAdvVoltages} \ctikzset{addmyv/.style = {v={#1}, !v sym, addcall={#1}}} \ctikzset{addcall/.code ={\addcommand{placesigns}{#1}}} \begin{document} \begin{tikzpicture} \draw (3,0) -- ++(1,0) coordinate(Rbot) to[R=R, name=vR, addmyv={$u_R$}] ++(0,+3) -- ++(-1,0); \draw (Rbot) -- ++(2,0) coordinate(Cbot) to[C=C, name=vC, addmyv={$u_C$}] ++(0,+3) -- ++(-2,0); \draw(Cbot) to [L=L, name=vL, addmyv={$u_L$}] ++(2,0); \DoAdvVoltages \end{tikzpicture} \end{document}

  • "Not in outer par mode" errors on intermediate compilations that resolve on later passes
    by RLH on January 18, 2026 at 7:07 pm

    I have a long document (600+ pages) that has been using \clearpage and \afterpage to force some page breaks and figure placement, and breakable tcolorboxes as example environments. This document occasionally gets into states where a fresh compile of the document completes without errors, the second compilation fails with ! 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 and the third and subsequent compilations succeed. Based on comments on my closed question \clearpage causes "not in outer par mode error" on second pass, I've found ways to reduce the use of \afterpage and to use non-float objects that otherwise behave like figures when I do need \afterpage, and have also tracked down my specific problem to an interaction between Floats in afterpage. Special footnote handling that uses shipout to move the footnote outside of the box. The presence of a long table of contents. (see demonstration code below) -- While I now understand more about what source-code patterns can produce these errors, I would stil like to better understand how the processing of the document leads to the specific error behavior. The error message (and other documentation of when the error is expected to appear) seems to indicate that the compiler is reading a \clearpage command at a point in the document which some internal state variable registers as being inside of a float. Combined with this error appearing on the second pass (when the TOC moves pages around) and its absence if the \tableofcontents call is removed, a parsimonious interpretation would be that either the location of the page breaks forced by \clearpage or the page numbers on which the floats appear are being retained from the previous pass, and so are triggering the error, even though \clearpage command does not appear inside float environment in the source code. Once the page locations have stabilized, the error goes away. Comments on my previous question suggested that this is not the correct model for how the error plays out at compilation time. What is a better way to understand the behavior of these kinds of errors that show up on intermediate compilations, but go away if I compile enough times? -- Code for generating the kind of errors that I'm encountering. This document should compile successfully on the first pass, error three times on the second and third passes, and then compile correctly on subsequent passes. \documentclass[11pt]{book} \usepackage{afterpage} \usepackage[many]{tcolorbox} \tcbuselibrary{magazine} % Not directly relevant here, but gets me a foreach function for the examples %%%%%%%% %%%%%%%% % Code for typesetting footnotes from tcolorboxes outside of the box, and in the main footnote sequence \newif\iffootaux \newcounter{footaux}% for \csname \newcounter{auxpage}% to handle frontmatter etc. \setcounter{auxpage}{1} \makeatletter \def\footnoteaux{\@ifnextchar[\@xfootnoteaux{\stepcounter{footnote}% \footnotemark[\thefootnote]\@footaux[\thefootnote]}} \def\@xfootnoteaux[#1]{\footnotemark[#1]\@footaux[#1]} \def\footaux{\@ifnextchar[\@footaux{\@footaux[\thefootnote]}} \def\@footaux[#1]#2{\protected@write{\@auxout}{\let\theauxpage\relax}{\string\newfootnote{\theauxpage}{#1}{#2}}} \newcommand{\newfootnote}[3]{% #1 = \theauxpage, #2 = \thefoontnote, #3 = text \ifnum#1=1\relax \footnotetext[#2]{#3}% \else \stepcounter{footaux}% \expandafter\xdef\csname footauxpage\thefootaux\endcsname{#1}% \expandafter\xdef\csname footauxnumber\thefootaux\endcsname{#2}% \expandafter\protected@xdef\csname footauxtext\thefootaux\endcsname{#3}% \fi} % to run at the end of every page (debug version) \newcommand{\addfootaux}{\loop \@ifundefined{footauxpage\thefootaux}{\footauxfalse}{% \count1=\csname footauxpage\thefootaux\endcsname\relax \advance\count1 by -1 \ifnum\count1=\value{auxpage}% \expandafter\let\expandafter\footauxnumber\csname footauxnumber\thefootaux\endcsname \expandafter\let\expandafter\footauxtext\csname footauxtext\thefootaux\endcsname \footnotetext[\footauxnumber]{\footauxtext}% \footauxtrue \else \footauxfalse \fi} \iffootaux \global\expandafter\let\csname footauxpage\thefootaux\endcsname\relax \global\expandafter\let\csname footauxnumber\thefootaux\endcsname\relax \global\expandafter\let\csname footauxtext\thefootaux\endcsname\relax \stepcounter{footaux}% \repeat \stepcounter{auxpage}} \makeatother \AtBeginDocument{\setcounter{footaux}{1}}% reset counter after \newfootnote \AddToHook{shipout/after}{\addfootaux} %%%%%%%% %%%%%%%% \newtcbtheorem[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} % Demonstration text \usepackage{lipsum} % Credit to musarithmia for Sator square % https://tex.stackexchange.com/a/208857 % Retrieved 2026-01-17, License - CC BY-SA 3.0 \newcommand{\satorsquare}{ {\huge\bfseries%\hfil% \begin{tabular}{|c|c|c|c|c|} \hline S & A & T & O & R\\ \hline A & R & E & P & O\\ \hline T & E & N & E & T\\ \hline O & P & E & R & A\\ \hline R & O & T & A & S\\ \hline \end{tabular}}} \begin{document} \title{Afterpage hammering to cause crash} \maketitle \tableofcontents % Generate enough text that the table of contents moves things across pages \foreach \n in {1,...,35} { \section{C} \lipsum[\n]%\footnote{This is a footnote from outside an example} } % Generate progressively longer examples with afterpaged figures \foreach \n in {1,...,3} { \typeout{On Example \n} % Put a float into an afterpage \afterpage{ \begin{figure} {\centering \satorsquare{} \caption{figure}{This is a Sator square} \label{fig:onesatorsquare\n} } \end{figure} } % Force a clearpage \clearpage % Typeset text in a breakable tcolorbox \begin{example}{Example}{exp\n} \lipsum[1-3] \lipsum[\n-\n+\n] \end{example} } % Generate progressively longer examples with afterpaged figures and footnotes handled with shipout \foreach \n in {1,...,3} { \typeout{On Example 3+\n} % Put a float into an afterpage \afterpage{ \begin{figure} {\centering \satorsquare{} \caption{figure}{This is a Sator square} \label{fig:onesatorsquare\n} } \end{figure}} % Force a clearpage \clearpage % Typeset text in a breakable tcolorbox with a footnote that is placed outside the box \begin{example}{Example}{exp\n} \lipsum[1-3]\footnote{This is a footnote from inside an example} \lipsum[\n-\n+\n] \end{example} } \end{document}

  • Inconsistent line thickness of \frac and \overline in PDF [closed]
    by The Little Blue Man on January 18, 2026 at 5:11 pm

    My problem Some of the lines in the PDF of my LaTeX document are different thicknesses. This applies to lines generated using the commands frac, \overline and underline (I'm not sure about the latter). Sometimes the thickness is correct, and sometimes it is much too thick. The thickness varies throughout the document and depending on the zoom level. My main issue is that it persists after printing the document. This problem don't affect lines generated by \rule or \hline. Here is an example: Some details I use LuaLaTeX. I use TexLive on Linux. Here are the packages I use: % Mandatory: \usepackage[french]{babel} \usepackage{graphicx} % — Maths — \usepackage{amssymb} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{stmaryrd} % - Addition of the mathscr font \usepackage[scr]{rsfso} \usepackage{fontspec} \usepackage{unicode-math} % Misc \usepackage{comment} \usepackage{geometry} \usepackage{titlesec} \usepackage[shortlabels]{enumitem} \usepackage{calc} \usepackage{lipsum} I use Latin Modern Math as my math font. What I have tried I tried several things that did not solve the issue: redefining \frac with \genfrac{}{}{0.4pt}{} I also tried adding the line '\fontdimen3\textfont3=0.4pt' (on the order of ChatGPT). I tried changing the maths font. Code that generate the problem \documentclass[12pt]{article} \title{Test} % --- Mandatory --- \usepackage[french]{babel} % --- Maths --- \usepackage{amssymb} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{stmaryrd} \usepackage[scr]{rsfso} \usepackage{fontspec} \usepackage{unicode-math} % ---- Fonts --- \setmathfont{Latin Modern Math} \setmathfont{STIX Two Math}[ % Utilisation de STIX Two uniquement pour mathbb range=bb, Scale=MatchUppercase ] \setmathfont{STIX Two Math}[ % Utilisation de STIX Two uniquement pour \varnothing range={\varnothing}, Scale=MatchUppercase ] \setmathfont{rsfso10}[ % Utilisation de rsfso10 uniquement pour mathscr range=scr, Scale=MatchUppercase ] \begin{document} \begin{align*} \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \frac{a}{b} & & \overline{A} \\ \end{align*} \end{document}

  • Error: "Missing \endgroup inserted." when using \multido with \tabularx environment
    by Jannik D. on January 18, 2026 at 5:04 pm

    I tried to fix this issue with ChatGPT but unfortunately I couldn't get it to work properly. I am trying to build a document in which I can input the number of exercises in an exam which then adjusts the header of a table. For example: If I input a number of 7 exercises, I want the header to have 7 columns in which I can later enter the achieved score of the students. Unfortunately I always get the error "Missing \endgroup inserted." and I somehow figured it has to do something with the combined use of \multidoand \tabularx. Can you help? \documentclass[a4paper,12pt]{article} \usepackage[landscape,margin=1.5cm]{geometry} \usepackage{tabularx,array,booktabs} \usepackage{forloop} \usepackage{multido} \usepackage{multicol} \usepackage[ngerman]{babel} % ----------------------------- % Einstellungen % ----------------------------- \newcommand\SAnz{30} % Number of pupils \newcommand\aufg{8} % Number of exercises \newcommand\saufg{3} % Number of extra exercises \newcommand{\AnzAufgaben}{ \multido{\i=1+1}{\aufg}{ \textbf{A\i} & }% } \newcommand{\AnzSAufgaben}{ \multido{\i=1+1}{\saufg}{ \textbf{$\ast$\i} & }% } \begin{document} \subsubsection*{Klausurstatistik Epoche THEMA -- Klasse XX -- Schuljahr XXXX/XXXX -- XXX, XXX} \begin{tabularx}{\linewidth}{| c||l|| *{\aufg}{c|} c|| *{\saufg}{c|} c||c|c||l|} \hline \textbf{V} & \textbf{Name} & \AnzAufgaben \textbf{$\Sigma$} & \AnzSAufg \textbf{$\Sigma(\star)$} & \textbf{\%} & \textbf{Note} & \textbf{Bemerkungen} \\ \hline\hline A/B & Musterlösung & 6 & 6 & 4 & 8 & 5 & 7 & & 43 & & & 13 & & & \\ \hline\hline \multido{\i=1+1}{\SAnz}{ & & & & & & & & & & & & & & & \\ \hline} \end{tabularx} \end{document} If you have any ideas on how to fix this or a workaround I'd be very grateful.

  • Reproducing figures with shaded half-planes in a gray square box
    by Sebastiano on January 18, 2026 at 4:43 pm

    I am trying to reproduce some images from old lecture notes, in particular notes by Prof. Gorni dating back to the 1993/94 academic year (pag. 4), or in other notes, like this picture At that time I had no knowledge of LaTeX at all. I do not know whether those figures were produced using PSTricks or with XFig/WinFig via psfrag, but my goal is to reproduce them in TikZ, correctly coloring the relevant half-planes. I am not completely sure whether it is possible (or appropriate) to modify the domain by introducing a square with a gray background or a path, but I have nevertheless quickly put together a minimal working example. \documentclass[a4paper,12pt]{article} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{arrows.meta,decorations.markings,backgrounds} \usepackage{geometry} \geometry{margin=2.5cm} \begin{document} \begin{center} \begin{tikzpicture}[scale=1.5] \draw[->] (-0.2,0) -- (2,0) node[right] {$x$}; \draw[->] (0,-0.2) -- (0,2) node[above] {$y$}; \def\a{1.75} \begin{scope}[on background layer] \fill[gray!25] (-\a,\a) -- (\a,\a) -- (\a,-\a) -- (-\a,\a) -- cycle; \end{scope} \draw[thick,white] (-\a,-\a) rectangle (\a,\a); \draw[thick] (-1.5,1.5) -- (1.5,-1.5); \node at (-1.25,0.55) {$y=-x$}; \draw[thick] ({sqrt(2)},0) arc (0:90:{sqrt(2)}); \fill (0,{sqrt(2)}) circle (0.6pt); \fill ({sqrt(2)},0) circle (0.6pt); \node[left] at (0,{sqrt(2)}) {$\left(0,\sqrt{2}\right)$}; \node[below] at ({sqrt(2)},0) {$\left(\sqrt{2},0\right)$}; \end{tikzpicture} \end{center} \end{document} The problems I am facing (also because I have never attempted anything like this before) are the red rectangles (I wonder if there is a simple option to place the arc vector in a central position):

  • For a simple math book, is it acceptable for the document background to be a color? [closed]
    by raulevm on January 18, 2026 at 2:01 pm

    \documentclass[twoside]{book} \usepackage[spanish]{babel} %----------------------------------------------------------------------------------------------------------------------- \usepackage[outer=0.625in, inner=0.875in, top=0.625in, bottom=0.75in]{geometry} %----------------------------------------------------------------------------------------------------------------------- \usepackage{tcolorbox} % %\definecolor{bg}{HTML}{E7E7E7} \definecolor{bg}{HTML}{E7E2DD} \definecolor{pbg}{HTML}{D4C3BB} \pagecolor{bg} %----------------------------------------------------------------------------------------------------------------------- \usepackage{titlesec} %\usepackage{titletoc} % \titleformat{\part}[display] {\sffamily\Huge\bfseries\centering} {\titleline{\titlerule}\vspace{1ex}\MakeUppercase{\partname\ \Roman{part}}} {1.5em} {\LARGE} [\vspace{1ex}\titleline{\titlerule}\clearpage] \titlespacing*{\part}{0pt}{4cm}{3cm} % \titleformat{\chapter}[display] {\sffamily\huge\bfseries\centering} {\chaptertitlename\ \Roman{chapter}} {2em} {\Huge} [\vfill\clearpage] % \titleformat{\section} {\sffamily\Large\bfseries}{\thesection}{1em}{} % \titleformat{\subsection} {\sffamily\large\bfseries}{\thesubsection}{1em}{} % \titleformat{\subsubsection} {\sffamily\normalsize\bfseries}{\thesubsubsection}{1em}{} %----------------------------------------------------------------------------------------------------------------------- \usepackage{tocloft} % \renewcommand{\cftchapfont}{\sffamily\bfseries} \renewcommand{\cftsecfont}{\sffamily} \renewcommand{\cftsubsecfont}{\sffamily} % \renewcommand{\cftsecaftersnum}{)} \renewcommand{\cftsubsecaftersnum}{)} \renewcommand{\cftsubsubsecaftersnum}{)} \renewcommand{\cftparaaftersnum}{)} \renewcommand{\cftsubparaaftersnum}{)} % \setlength{\cftsecnumwidth}{2.5em} \setlength{\cftsubsecnumwidth}{3.5em} \setlength{\cftsubsubsecnumwidth}{4.5em} %----------------------------------------------------------------------------------------------------------------------- \usepackage{unicode-math} % \setmainfont{texgyreadventor}[ UprightFont=*-regular, ItalicFont=*-italic, BoldFont=*-bold, BoldItalicFont=*-bolditalic ] % \setsansfont{Palmont-Regular}[ Path=../Fonts/, Extension=.otf, Scale=MatchUppercase ] % \setmonofont{BodoniC}[ Path=../Fonts/, Extension=.otf, UprightFont=*-Regular, ItalicFont=*-Italic, BoldFont=*-Bold, BoldItalicFont=*-BoldItalic, Scale=MatchLowercase ] % \setmathfont{OldStandard-Math} \setmathfont{texgyreschola-math}[range={\lgroup,\rgroup}] \setmathfont{texgyretermes-math}[range={\in,\notin,\forall,\exists}] \setmathfont{KpMath-Sans}[range=bb] \setmathfont{BodoniC-Regular}[Path=../Fonts/,Extension=.otf,range=up/num] \setmathfont{BodoniC-Italic}[Path=../Fonts/,Extension=.otf,range=it/{latin,Latin}] \setmathfont{OldStandard-Math}[range={}] % %----------------------------------------------------------------------------------------------------------------------- \usepackage{amsthm} \usepackage{thmtools} % \declaretheoremstyle[ headfont=\small\sffamily, headpunct={\hrulefill\\[1ex]}, headformat={% \tcbox[arc=1pt,sharp corners,rounded corners=west,boxsep=2pt,top=0.4pt,bottom=0.4pt,left=2pt,right=0pt,boxrule=0.4pt,colback=pbg,colframe=pbg,colupper=black]{\NAME}% \tcbox[arc=1pt,sharp corners,rounded corners=northeast,boxsep=2pt,top=0.4pt,bottom=0.4pt,left=0pt,right=0pt,boxrule=0.4pt,colback=black,colframe=black,colupper=bg]{\NUMBER}% } ]{problem-style} % \declaretheorem[ numberwithin=section, name=PROBLEMA, style=problem-style ]{problem} %----------------------------------------------------------------------------------------------------------------------- \AtBeginDocument{ \let\Rightarrow\implies \let\Leftrightarrow\iff \let\xland\wedge \renewcommand{\land}{\;\xland\;} \let\wedge\land \let\xlor\vee \renewcommand{\lor}{\;\xlor\;} \let\vee\lor } %----------------------------------------------------------------------------------------------------------------------- \renewcommand{\sin}{\operatorname{\symit{sen}}} \renewcommand{\cos}{\operatorname{\symit{cos}}} \renewcommand{\tan}{\operatorname{\symit{tg}}} \renewcommand{\arcsin}{\operatorname{\symit{arcsen}}} \renewcommand{\arccos}{\operatorname{\symit{arccos}}} \renewcommand{\arctan}{\operatorname{\symit{arctg}}} \renewcommand{\sinh}{\operatorname{\symit{senh}}} \renewcommand{\cosh}{\operatorname{\symit{cosh}}} \renewcommand{\tanh}{\operatorname{\symit{tgh}}} \renewcommand{\ln}{\operatorname{\symit{ln}}} \renewcommand{\log}{\operatorname{\symit{log}}} %----------------------------------------------------------------------------------------------------------------------- \usepackage{booktabs} \usepackage{caption} %----------------------------------------------------------------------------------------------------------------------- \usepackage{enumitem} %----------------------------------------------------------------------------------------------------------------------- \usepackage{multicol} % \setlength{\columnseprule}{.4pt} %----------------------------------------------------------------------------------------------------------------------- \usepackage{fancyhdr} % \pagestyle{fancy} \renewcommand{\chaptermark}[1]{\markboth{#1}{}} \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} \renewcommand{\subsectionmark}[1]{\markright{\thesubsection\ #1}} \fancyhf{} \fancyhead[LE,RO]{\sffamily\thepage} \fancyhead[LO]{\sffamily\rightmark} \fancyhead[RE]{\sffamily\leftmark} \renewcommand{\headrulewidth}{0.8pt} \renewcommand{\footrulewidth}{0pt} \addtolength{\headheight}{0.8pt} \setlength{\footskip}{0in} \renewcommand{\footruleskip}{0pt} \fancypagestyle{plain}{% \fancyhead{} \renewcommand{\headrulewidth}{0pt} } %----------------------------------------------------------------------------------------------------------------------- \begin{document} \part{EL SISTEMA DE LOS NÚMEROS REALES} \chapter{RELACION DE IGUALDAD} \section{PROBLEMAS RESUELTOS} \begin{problem}Demuestre las siguientes propiedades algebraicas. \begin{multicols}{2} \begin{enumerate}[itemsep=1em,label=\bfseries\arabic*.] \item $\forall a \in \mathbb{R} \quad : \quad a0 = 0$ \item $\forall a \in \mathbb{R} \quad : \quad ( - 1)a = - a$ \item $\forall a,b \in \mathbb{R} \quad : \quad a( - b) = - (ab) = ( - a)b$ \item $\forall a \in \mathbb{R} \quad : \quad - ( - a) = a$ \item $\forall a,b \in \mathbb{R} \quad : \quad ( - a)( - b) = ab$ \item $...$ \item $...$ \item $...$ \item $...$ \item $...$ \end{enumerate} \end{multicols} \end{problem} \end{document}

  • ConTeXt: per-chapter bibliography section with its own numbering
    by Georgian Ilie on January 18, 2026 at 1:15 pm

    Good afternoon, I am trying to type my first book in ConTeXt. My intent is to produce a bibliographic section at the end of each chapter. Regarding the citations, I would like that: First, they appear as superscripts. Second, each citation for each chapter has appended a letter of the alphabet—say "A" for chapter one, "B" for chapter two etc. In addition, I would like that the superscript citation appears also as an entry into the bibliography—like this: The bibliography file where I setup the appearance has this code: \unprotect \loadbtxdefinitionfile[aps] \setupbtx[aps:list][ authorconversion=invertedshort, stopper:initials={.\btxspace}, separator:names:2={\removeunwantedspaces\btxsemicolon}, separator:names:3={\removeunwantedspaces\btxsemicolon}, separator:names:4={\removeunwantedspaces\btxsemicolon}, ] \setupbtx[aps:list:numbering][ left={(}, right={)}, ] \setupbtxlist[ distance=0pt, width=2.5em, align=flushleft, ] \setupbtx[aps:list:volume][style=italic] \setupbtx[aps:list:title:electronic][style=,] \starttexdefinition mutable protected btx:aps:author \btxdoif {author} { \btxflush{author} } \stoptexdefinition \starttexdefinition mutable protected btx:aps:title \btxdoifelse {title} { \texdefinition{btx:aps:composed-title}{title} \btxperiod } { \removepunctuation } \stoptexdefinition \starttexdefinition mutable protected btx:aps:journal-volume-year \btxdoif {journal} { \btxspace \btxstartstyleandcolor[aps:list:journal] \btxflush{expandedjournal -> journal} \btxstopstyleandcolor \btxdoif {year} { \btxspace \bold{\texdefinition{btx:aps:year}} \btxcomma } \btxdoif {volume} { \btxspace \btxstartstyleandcolor [aps:list:volume] \btxflush{volume} \btxstopstyleandcolor \btxcomma } \btxdoif {pages} { \btxspace \btxflush{pages} } } \stoptexdefinition \starttexdefinition mutable protected btx:aps:editionset \removeunwantedspaces \removepunctuation \btxdoif {edition} { \btxcomma \begingroup\pushoverloadmode \def\highordinalstr##1{##1} \ordinalnumber{\btxflush{edition}} \popoverloadmode\endgroup \btxspace \btxlabeltext{aps:edition} \btxsemicolon } \doif {\currentbtxcategory} {techreport} { \btxsemicolon \btxdoifelse {type} { \btxusecommand [\currentbtx:type] { \btxflush{type} } } { \btxlabeltext{technicalreport} } } \btxdoif {volume} { \btxcomma \btxoneorrange {volume} { \btxlabeltext{aps:Volume} } { \btxlabeltext{aps:Volumes} } \btxspace \btxflush{volume} \btxcomma } \btxdoif {number} { \removeunwantedspaces \removepunctuation \btxspace \btxflush{number} \btxcomma } \btxdoif {pages} { \btxoneorrange {pages} { \btxlabeltext{p} } { \btxlabeltext{pp} } \btxnbsp \btxflush{pages} \btxcomma } \stoptexdefinition \starttexdefinition mutable protected btx:aps:publisher-wherefrom-year \removeunwantedspaces \removepunctuation \btxsemicolon \btxdoifelse {institution} { \btxdoif {address} { \btxflush{address} \btxcolon } \btxflush{institution} \btxcomma } { \btxflush{publisher} \btxdoifelse {address} { \btxdoif {publisher} { \btxcolon } \btxflush{address} \btxcomma } { \btxdoif {publisher} { \btxcomma } } } \texdefinition{btx:aps:year} \stoptexdefinition \protect \usebtxdefinitions[aps] \usemodule[bibtex] \enabletrackers[publications, publications.crossref, publications.details, publications.cite, publications.strings] \definebtxrendering[bibrendering][aps][dataset=main] \usebtxdataset[default][Parts/Bibliography/Bibliografia.bib] \defineconversion[dynamicAlpha][\Characters{\getmarking[chapternumber]}-\numbers] \setupbtx[default:cite][ alternative=superscript, numberconversion=dynamicAlpha, ] \setupbtx[default:list][ numberconversion=dynamicAlpha, ] \setupbtxrendering[default][ specification=aps, dataset=default, criterium=chapter ] Thank you in advance for the attention and the help. EDIT Below I share a MWE: %Bibliography style Parts \unprotect \setupbtx[aps:list][ authorconversion=invertedshort, stopper:initials={.\btxspace}, separator:names:2={\removeunwantedspaces\btxsemicolon}, separator:names:3={\removeunwantedspaces\btxsemicolon}, separator:names:4={\removeunwantedspaces\btxsemicolon}, ] \setupbtx[aps:list:numbering][ left={(}, right={)}, ] \setupbtxlist[ distance=0pt, width=2.5em, align=flushleft, ] \setupbtx[aps:list:volume][style=italic] \setupbtx[aps:list:title:electronic][style=,] \starttexdefinition mutable protected btx:aps:author \btxdoif {author} { \btxflush{author} } \stoptexdefinition \starttexdefinition mutable protected btx:aps:title \btxdoifelse {title} { \texdefinition{btx:aps:composed-title}{title} \btxperiod } { \removepunctuation } \stoptexdefinition \starttexdefinition mutable protected btx:aps:journal-volume-year \btxdoif {journal} { \btxspace \btxstartstyleandcolor[aps:list:journal] \btxflush{expandedjournal -> journal} \btxstopstyleandcolor \btxdoif {year} { \btxspace \bold{\texdefinition{btx:aps:year}} \btxcomma } \btxdoif {volume} { \btxspace \btxstartstyleandcolor [aps:list:volume] \btxflush{volume} \btxstopstyleandcolor \btxcomma } \btxdoif {pages} { \btxspace \btxflush{pages} } } \stoptexdefinition \starttexdefinition mutable protected btx:aps:editionset \removeunwantedspaces \removepunctuation \btxdoif {edition} { \btxcomma \begingroup\pushoverloadmode \def\highordinalstr##1{##1} \ordinalnumber{\btxflush{edition}} \popoverloadmode\endgroup \btxspace \btxlabeltext{aps:edition} \btxsemicolon } \doif {\currentbtxcategory} {techreport} { \btxsemicolon \btxdoifelse {type} { \btxusecommand [\currentbtx:type] { \btxflush{type} } } { \btxlabeltext{technicalreport} } } \btxdoif {volume} { \btxcomma \btxoneorrange {volume} { \btxlabeltext{aps:Volume} } { \btxlabeltext{aps:Volumes} } \btxspace \btxflush{volume} \btxcomma } \btxdoif {number} { \removeunwantedspaces \removepunctuation \btxspace \btxflush{number} \btxcomma } \btxdoif {pages} { \btxoneorrange {pages} { \btxlabeltext{p} } { \btxlabeltext{pp} } \btxnbsp \btxflush{pages} \btxcomma } \stoptexdefinition \starttexdefinition mutable protected btx:aps:publisher-wherefrom-year \removeunwantedspaces \removepunctuation \btxsemicolon \btxdoifelse {institution} { \btxdoif {address} { \btxflush{address} \btxcolon } \btxflush{institution} \btxcomma } { \btxflush{publisher} \btxdoifelse {address} { \btxdoif {publisher} { \btxcolon } \btxflush{address} \btxcomma } { \btxdoif {publisher} { \btxcomma } } } \texdefinition{btx:aps:year} \stoptexdefinition \protect \usebtxdefinitions[aps] \usemodule[bibtex] \enabletrackers[publications, publications.crossref, publications.details, publications.cite, publications.strings] \definebtxrendering[bibrendering][aps][dataset=main] \usebtxdataset[default][Parts/Bibliography/Bibliografia.bib] \defineconversion[dynamicAlpha][\Characters{\getmarking[chapternumber]}-\numbers] \setupbtx[default:cite][ alternative=superscript, numberconversion=dynamicAlpha, ] \setupbtx[default:list][ numberconversion=dynamicAlpha, ] \setupbtxrendering[default][ specification=aps, dataset=default, criterium=chapter ] %Bibliography style Parts \usebtxdefinitions[aps] \startbuffer[biblatex-chem] @Techreport{Allen1961, hyphenation = {british}, author = {Allen, R. A. and Smith, D. B. and Hiscott, J. E.}, title = {Radioisotope Data}, institution = {H.M.S.O.}, address = {London}, type = {UKAEA Research Group Report}, number = {AERE-R 2938}, year = {1961} } \stopbuffer \usebtxdataset[biblatex-chem.buffer] \starttext \chapter[title=Hello] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id maximus lorem, vitae sagittis massa. Sed non euismod turpis. Vestibulum aliquet augue magna, sed aliquet enim consectetur laoreet. Quisque egestas sed ante ut lobortis. In laoreet mauris nisi, nec vehicula nibh fermentum vitae. Cras nec ultricies diam. Aliquam ipsum sapien, facilisis vitae augue ut, consectetur suscipit magna. Praesent nec nunc posuere eros hendrerit placerat. Aenean in accumsan ligula. Mauris ultricies, risus ullamcorper luctus gravida, nisl odio feugiat orci, a tristique ex mi eget magna. Ut in justo ultricies, blandit leo sed, scelerisque tellus. Phasellus imperdiet dignissim mauris. Vestibulum vitae leo eu ex lacinia facilisis non luctus nisi. Nullam ornare, tortor nec porta gravida, justo purus elementum ligula, sit amet iaculis nunc ipsum mollis justo. Maecenas dignissim lectus et luctus viverra. \cite[Allen1961] \stopchapter \starttitle[title=Bibliography] \placelistofpublications \stoptitle \stoptext Thank you advance for your patience. EDIT II Below I provide a MWE based on the code above: I have removed the part relating to the styling of the bibliography and inserted another chapter with a second citation. \startbuffer[biblatex-chem] @Techreport{Allen1961, hyphenation = {british}, author = {Allen, R. A. and Smith, D. B. and Hiscott, J. E.}, title = {Radioisotope Data}, institution = {H.M.S.O.}, address = {London}, type = {UKAEA Research Group Report}, number = {AERE-R 2938}, year = {1961} } @Article{Arduengo1991, hyphenation = {american}, author = {Arduengo, III, Anthony J. and Harlow, Richard L. and Kline, Michael}, title = {A stable crystalline carbene}, journal = {J.~Am. Chem. Soc.}, year = {1991}, volume = {113}, pages = {361--363}, number = {1}, doi = {10.1021/ja00001a054}, annotation = {An article with ``III'' in the author section} } \stopbuffer \usebtxdataset[biblatex-chem.buffer] \starttext \chapter[title=Hello] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id maximus lorem, vitae sagittis massa. Sed non euismod turpis. Vestibulum aliquet augue magna, sed aliquet enim consectetur laoreet. Quisque egestas sed ante ut lobortis. In laoreet mauris nisi, nec vehicula nibh fermentum vitae. Cras nec ultricies diam. Aliquam ipsum sapien, facilisis vitae augue ut, consectetur suscipit magna. Praesent nec nunc posuere eros hendrerit placerat. Aenean in accumsan ligula. Mauris ultricies, risus ullamcorper luctus gravida, nisl odio feugiat orci, a tristique ex mi eget magna. Ut in justo ultricies, blandit leo sed, scelerisque tellus. Phasellus imperdiet dignissim mauris. Vestibulum vitae leo eu ex lacinia facilisis non luctus nisi. Nullam ornare, tortor nec porta gravida, justo purus elementum ligula, sit amet iaculis nunc ipsum mollis justo. Maecenas dignissim lectus et luctus viverra. \cite[Allen1961] \stopchapter \chapter[title=Bonsoir] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam id maximus lorem, vitae sagittis massa. Sed non euismod turpis. Vestibulum aliquet augue magna, sed aliquet enim consectetur laoreet. Quisque egestas sed ante ut lobortis. In laoreet mauris nisi, nec vehicula nibh fermentum vitae. Cras nec ultricies diam. Aliquam ipsum sapien, facilisis vitae augue ut, consectetur suscipit magna. Praesent nec nunc posuere eros hendrerit placerat. Aenean in accumsan ligula. Mauris ultricies, risus ullamcorper luctus gravida, nisl odio feugiat orci, a tristique ex mi eget magna. Ut in justo ultricies, blandit leo sed, scelerisque tellus. Phasellus imperdiet dignissim mauris. Vestibulum vitae leo eu ex lacinia facilisis non luctus nisi. Nullam ornare, tortor nec porta gravida, justo purus elementum ligula, sit amet iaculis nunc ipsum mollis justo. Maecenas dignissim lectus et luctus viverra. \cite[Arduengo1991] \stopchapter \starttitle[title=Bibliography] \placelistofpublications \stoptitle \stoptext

  • chemnum: How to create an alias compound label so two IDs print the same number (without breaking numbering)?
    by taiwan12 on January 18, 2026 at 1:10 pm

    This \newcommand only works in the simplest cases and breaks as soon as multiple aliases are defined or new compounds are introduced later. \documentclass{article} \usepackage{chemnum} \newcommand\makecmpdalias[2]{% % ensure target exists (without printing) \cmpd*{#1}% % define alias label (without printing) \cmpd*{#2}% % copy printed representation from #1 to #2 \setcmpdlabel{#2}{\cmpdproperty{#1}{counter-representation}}% % undo the counter step caused by defining #2 \addtocounter{cmpdmain}{-1}% } \begin{document} \makecmpdalias{A}{B} \makecmpdalias{D}{E} \makecmpdalias{F}{H} \cmpd{A} \cmpd{B} \cmpd{A,B} \cmpd{C} \cmpd{D} \cmpd{E} \cmpd{F} \cmpd{G} \cmpd{H} \cmpd{I} \end{document} I am using chemnum and referencing compounds via \cmpd{...}. What I want is a simple alias mechanism: \cmpd{A} should define/print compound 1 after \makecmpdalias{A}{B}, \cmpd{B} should also print 1 (B is an alias for A) importantly, the next new compound should continue numbering normally, so \cmpd{C} should print 2 (not 3) similarly D and E should share one number. Expected output: 1 1 1 and 1 2 3 3 4 5 4 6 Actual output with my attempt: So the numbering becomes out of order (C becomes 3, then D/E become 2)....

  • overprint(-like) behavior with frame number increases and beamerpause handling
    by scottkosty on January 18, 2026 at 10:33 am

    I would like to make a set of frames that behave like overprint, but where the frame number increases automatically and where beamerpauses is set such that \beamerdefaultoverlayspecification{<alert@+|+->} formats things automatically. Below I give an example that compiles and does show the output that I want for this particular document, but I've hacked things (i.e., experimented and copy/pasted things that I don't even understand) so much I'm hoping there is a better way. That is, I fear I am abusing the overprint environment and I should be doing things fundamentally a different way. Is there a more "natural" Beamer way to do this, but still with automating the things I want (i.e., avoiding hardcoding of overlay numbers as much as possible and keeping the body of the document as simple as possible even if a long preamble is needed)? Also, I do not want to copy/paste/repeat any content. I would prefer hackish, if necessary, over duplicate content across frames. \documentclass{beamer} \setbeamertemplate{footline}[frame number]{} \beamerdefaultoverlayspecification{<alert@+|+->} % THE REST OF THIS PREAMBLE INJECTS INCREMENTING THE FRAME NUMBER FOR EACH % \onslide AND IT ALSO SETS THE "BEAMERPAUSES" COUNTER APPROPRIATELY. \makeatletter \newcount\my@onslide@first % Compute the first (minimum) overlay number that Beamer decodes from <#1>, % respecting + and . forms, without consuming a pause. \def\my@onslide@getfirst#1{% \begingroup % save state that the decoder mutates globally \count@\beamer@minimum \@tempcnta=\value{beamerpauses}% % prevent the probe decode from advancing beamerpauses \let\my@orig@stepcounter\stepcounter \def\stepcounter##1{% \edef\my@tmp{##1}% \edef\my@bp{beamerpauses}% \ifx\my@tmp\my@bp % no-op \else \my@orig@stepcounter{##1}% \fi }% % run Beamer's overlay-spec decoder \beamer@masterdecode{#1}% % capture the decoded minimum overlay \global\my@onslide@first=\beamer@minimum\relax % restore mutated globals \global\beamer@minimum=\count@\relax \global\setcounter{beamerpauses}{\the\@tempcnta}% \endgroup } % Wrap \onslide (star + nonstar), only when a <...> spec is present \let\my@orig@onslide\onslide \def\onslide{% \@ifstar{\my@onslide@wrapstar}{\my@onslide@wrapnostar}% } \def\my@onslide@wrapnostar{% \@ifnextchar<{\my@onslide@withspec}{\my@orig@onslide}% } \def\my@onslide@wrapstar{% \@ifnextchar<{\my@onslide@withspecstar}{\my@orig@onslide*}% } \def\my@onslide@withspec<#1>{% \my@onslide@getfirst{#1}% % automate the trick here: % https://tex.stackexchange.com/questions/329956/beamer-keep-text-position-in-consecutive-frames-or-how-to-get-overprint-to-inc \only<\the\my@onslide@first>{\stepcounter{framenumber}}% % make it so that the default overlay increment works. \setcounter{beamerpauses}{\the\my@onslide@first}% \my@orig@onslide<#1>% } \def\my@onslide@withspecstar<#1>{% \my@onslide@getfirst{#1}% \only<\the\my@onslide@first>{\stepcounter{framenumber}}% \setcounter{beamerpauses}{\the\my@onslide@first}% \my@orig@onslide*<#1>% } \makeatother \begin{document} \begin{frame} Definitition: Let $X$ be a rv. Then, $X$ is a \emph{continuous rv} if there exists a function, $f_{X}:\mathbb{R}\mapsto[0,\infty)$, called a \emph{probability density function (pdf)}, such that for any numbers $c_{1}\le c_{2}$, \[ Pr(X\in[c_{1},c_{2}])=Pr({c_{1}}\le X\le c_{2})=\int^{c_{2}}_{c_{1}}f_{X}(x)dx. \] \begin{overprint} % Possible to automate this also? i.e., make it so whenever % overprint environment begins, we subtract 1 (because the first \onslide % will add 1 when I don't want it to. \only<2>{\addtocounter{framenumber}{-1}} \onslide<2|handout:1> \begin{block}{} Here I show a graph of a pdf. (place holder for the graph) \end{block} \onslide<3-5|handout:2> Here are some properties: \begin{itemize} \item one \item two \item three \end{itemize} \onslide<6-10|handout:3> Some important implications: \begin{itemize} \item Implication 1 \item Implication 2 \end{itemize} \begin{block}{} Some important implications and a couple of final points below. \begin{enumerate} \item Important point 1 \item Important point 2 \end{enumerate} \end{block} \end{overprint} \end{frame} \end{document} Here I show the output from the compiled document, which is indeed the output that I want:

  • Alternative symbol (curlyvee) with arrow
    by Lukas Grätz on January 18, 2026 at 10:21 am

    I was looking for a symbol to display the alternative like || or \vee but with some kind of pointer to the choice. I thank that \curlyvee with a left/right arrow would be perfect: Can someone help me how to typeset these two symbols? Thank you in advance! \documentclass{article} \usepackage{amsmath} \usepackage{amssymb} \begin{document} \begin{align*} a &\curlyvee b \\ a &\curlyvee b = a % \curlyveeleft \\ a &\curlyvee b = b % \curlyveeright \end{align*} \end{document}

  • How to return array from a command?
    by karu on January 18, 2026 at 10:07 am

    How to return an array from a command? or rather How to expand a command to some generated array? The code below generates the correct array into \OutArray inside \Transmogrifier, but I don't know how to return it to calling \ResultArray. I know one option to access the values is to define an empty array, give the array as an argument to the command, have the command generate the elements to that array and access them when the command is finished. This is not what I am looking for. My question is more to expand my understanding and increase the tools I have in my disposal. \documentclass[tikz]{standalone} \begin{document} \newcommand*{\SomeOperation}[2]{% \fpeval{#1*#2}% }% \newcommand*{\Transmogrifier}[2]{% \pgfmathparse{dim(#1)}% or \pgfmathdim{#1}% \edef\ArrayLength{\pgfmathresult}% \xdef\OutArray{{}}% \foreach \i in {0,...,\fpeval{\ArrayLength-1}}% {% \pgfmathparse{array({#1},\i)}% or \pgfmatharray{{#1}}{\i}% \ifnum \i=0% \xdef\OutArray{\SomeOperation{\pgfmathresult}{#2}}% \else% \xdef\OutArray{\OutArray,\SomeOperation{\pgfmathresult}{#2}}% \fi% }% \xdef\OutArray{{\OutArray}}% How to "return" \OutArray? %\typeout{OutArray: \OutArray}% }% \begin{tikzpicture} \def\TestArray{{1,2,3}}% \typeout{TestArray: \TestArray}% \newcommand*{\ResultArray}{% \Transmogrifier{\TestArray}{2}% }% %\ResultArray% Temp for testing \typeout{ResultArray: \ResultArray}% \end{tikzpicture} \end{document} Desired outcome in the log file: TestArray: {1,2,3} ResultArray: {2,4,6}

  • Indifference and budget curve
    by henry on January 18, 2026 at 8:26 am

    I have a trouble to draw this diagram, could you guys help me please. This is my code: \begin{frame}{5.2.Child-care subsidy} \vspace{0.1cm} \centering \resizebox{0.95\textwidth}{!}{% \begin{tikzpicture}[scale=0.95, >=Stealth, font=\sffamily] % --- 1. HỆ TRỤC --- \draw[thick] (0,0) -- (0,6.5) node[above] {Income}; \draw[thick] (0,0) -- (6.5,0); \node[below left] at (0,0) {0}; \node[below] at (5.5,0) {$\longleftarrow$ Hours of Paid Work}; \coordinate (a) at (6.0, 0); \coordinate (c) at (6.0, 1.5); \coordinate (b) at (6.0, 3.0); \draw[thin, gray!30] (6.0, 0) -- (6.0, 3.2); \filldraw[black] (a) circle (1.5pt) node[right, font=\scriptsize] {$a$}; \filldraw[black] (c) circle (1.5pt) node[right, font=\scriptsize] {$c$}; \filldraw[black] (b) circle (1.5pt) node[right, font=\scriptsize] {$b$}; % Đường thấp d-c \coordinate (d) at (0, 4.0); \draw[thick, cyan!50] (d) node[left, black, font=\scriptsize] {$d$} -- (c); \coordinate (e) at (0, 5.5); \draw[thick, curveBlue] (e) node[left, black, font=\scriptsize] {$e$} -- (b); \coordinate (X) at (2.4, 3.0); \filldraw[black] (X) circle (2pt) node[below left] {$X$}; \coordinate (Y) at (3.6, 4.0); \filldraw[black] (Y) circle (2pt) node[above right] {$Y$}; \draw[thick, black] (0.6, 5.2) .. controls (1.2, 3.8) and (1.8, 2.9) .. (X) .. controls (3.2, 3.1) and (5.0, 2.5) .. (6.2, 4.0) node[right] {$U_1$}; \draw[thick, black] (1.5, 6.5) .. controls (2.2, 5.0) and (2.8, 3.9) .. (Y) .. controls (4.5, 4.1) and (5.5, 4.2) .. (6.2, 5.8) node[right] {$U_3$}; \draw[thick, black!70] (1.0, 6.0) .. controls (1.8, 4.5) and (2.5, 3.5) .. (3.1, 3.6) .. controls (4.0, 3.7) and (5.2, 3.5) .. (6.2, 5.0) node[right] {$U_2$}; \end{tikzpicture} } This is what i get:

  • 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>)?

  • MikTex require Alegreya TTC?
    by nana on January 18, 2026 at 3:20 am

    I used to have Alegreya font installed (presumably from google since it inception). As I migrated to a new system MikTeX said the Alegreya font I installed is not a TTC. Yes, it is indeed TTF from google package. But why I used to have no problem? What should I do now? Where to download a TTC Alegreya ?

  • Set xmp description for other languages too
    by HerpDerpington on January 18, 2026 at 1:50 am

    The xmp description can be set for example using hyperref: \DocumentMetadata{ lang=en-US } \documentclass{article} \usepackage{hyperref} \hypersetup{ pdfsubject={This will end up as the english subject.} } \begin{document} test \end{document} exiftool then reveals: Description : This will end up as the english subject. Description (en-US) : This will end up as the english subject. Language : en-US coming from the XMP block [...] <dc:description> <rdf:Alt> <rdf:li xml:lang="x-default">This will end up as the english subject.</rdf:li> <rdf:li xml:lang="en-US">This will end up as the english subject.</rdf:li> </rdf:Alt> </dc:description> [...] which seems to suggest that the Description may also be set for other languages. How can I for example set the description for something like de-DE?

  • How to add/calculate integers that are coming from a macro using LaTeX3?
    by lukascbossert on January 17, 2026 at 11:23 pm

    In my example I want to calculate integers / getting the sum of entries based on various filtering options. Instead of using datatools macros, I’d like to get it done with LaTeX3/expl3-commands. The problem is the part: \int_set:Nn \l_tmpb_int { \dfgCountPosition[#1]{#2}{f} } which tells me in the log: ! Missing number, treated as zero. <to be read again> \xparse function is not expandable l.94 .../d): \dfgTotalPosition{PostDoc} but as far as I can see there is no \int_set:Nx for using an expansion therefor this is not the solution. So, how can I calculate the sum of entries based on the filter criteria? Here is my MWE \documentclass{article} \usepackage{expl3} % expl3 kernel \usepackage{datatool} % CSV handling \newcommand{\theFundingPeriodNumeral}{3} \ExplSyntaxOn %------------------------------------------------- % 1. Counting routine (optional DB argument) % \dfgCountPosition[<db>]{<position>}{<gender>} % → plain integer %------------------------------------------------- \NewDocumentCommand{\dfgCountPosition}{ O{mydb} m m } { % #1 = database name (default = mydb) % #2 = position (e.g. PostDoc) % #3 = gender (f / m / d) \group_begin: \def\dfgLocalDB{#1} \clist_clear:N \l_tmpa_clist \seq_clear:N \l_tmpb_seq \DTLforeach* [ \DTLiseq{#2}{\pPosition} \and \DTLiseq{#3}{\pGender} \and \DTLisinlist{PI}{\pRole} ] {\dfgLocalDB}{% \pID=id, \pPosition=position,% \pPeriod=period,% \pGender=gender,% \pRole=role }{ % using ID here because this is always one element \clist_put_right:NV \l_tmpa_clist {\pID} } \clist_count:N \l_tmpa_clist \group_end: } %------------------------------------------------- % 2. Total of the three genders for a given position % \dfgTotalPosition[<db>]{<position>} % → plain integer (f+m+d) %------------------------------------------------- \NewDocumentCommand{\dfgTotalPosition}{ O{mydb} m } { % start with the female count \int_set:Nn \l_tmpb_int { \dfgCountPosition[#1]{#2}{f} } % add the male count \int_add:Nn \l_tmpb_int { \dfgCountPosition[#1]{#2}{m} } % add the “diverse” count \int_add:Nn \l_tmpb_int { \dfgCountPosition[#1]{#2}{d} } % finally output the total \int_use:N \l_tmpb_int } \ExplSyntaxOff %------------------------------------------------- %------------------------------------------------- % Create a tiny CSV file that the example can read % ------------------------------------------------- \begin{filecontents*}{mydata.csv} id,position,period,gender,role 1,PostDoc,"2,3",f,PI 2,PostDoc,"1,2,3",m,PI 3,PostDoc,2,f,PI 4,PostDoc,3,d,PI 5,GroupLeader,3,m,PI 6,GroupLeader,2,f,PI 7,GroupLeader,3,m,PI 8,GroupLeader,2,d,PI 9,PhD,3,f,PI 10,PhD,2,m,PI \end{filecontents*} % Load the CSV into a datatool table called “mydb” \DTLloaddb{mydb}{mydata.csv} \begin{document} \section*{Demo of the two macros} \textbf{Counts for a single gender / position}\\[2mm] Females among PostDocs: \dfgCountPosition{PostDoc}{f}\\ Males among PostDocs: \dfgCountPosition{PostDoc}{m}\\ Diverse among PostDocs: \dfgCountPosition{PostDoc}{d}\\[2mm] \textbf{Total number of persons for a position}\\[2mm] All PostDocs (f/m/d): \dfgTotalPosition{PostDoc}\\ All GroupLeaders (f/m/d): \dfgTotalPosition{GroupLeader}\\ All PhDs (f/m/d): \dfgTotalPosition{PhD}\\[2mm] \textbf{Using a non‑default database (just to show the syntax)}\\[2mm] Females in the table “mydb” (same table here): \dfgCountPosition[mydb]{PhD}{f} \end{document}

  • "[H]" command is not working even I used float package [duplicate]
    by Ege Tunç on January 17, 2026 at 8:19 pm

    I used float package and here's an example of my graphs: \begin{figure}[H] \centering \subfloat[ObsID 4201960130]{\includegraphics[width=0.3\textwidth]{type2comptt/1.png}}\hfill \subfloat[ObsID 4201960131]{\includegraphics[width=0.3\textwidth]{type2comptt/2.png}}\hfill \subfloat[ObsID 4201960132]{\includegraphics[width=0.3\textwidth]{type2comptt/3.png}}\\[2mm] \subfloat[ObsID 4201960133]{\includegraphics[width=0.3\textwidth]{type2comptt/4.png}}\hfill \subfloat[ObsID 4201960134]{\includegraphics[width=0.3\textwidth]{type2comptt/5.png}}\hfill \subfloat[ObsID 4201960135]{\includegraphics[width=0.3\textwidth]{type2comptt/6.png}}\\[2mm] \subfloat[ObsID 4201960136]{\includegraphics[width=0.3\textwidth]{type2comptt/7.png}}\hfill \subfloat[ObsID 4201960137]{\includegraphics[width=0.3\textwidth]{type2comptt/8.png}}\hfill \subfloat[ObsID 4201960138]{\includegraphics[width=0.3\textwidth]{type2comptt/9.png}} \caption{Appendix figure: Type-II fits of \texttt{tbabs*(comptt + gauss)} model.} \label{fig:appendix1} \end{figure} whatever i do, i see "[H]" in text and cannot place the graph where i wanted Solved: "From the MNRAS LaTeX guide for authors: "The LATEX float placement commands [htbp] are intentionally disabled. Layout of figures and tables will be adjusted by the publisher during the production process, so authors should not concern themselves with placement to avoid disappointment and wasted effort. Simply place the LATEX code close to where the figure or table is first mentioned in the text and leave exact placement to the publishers.

  • 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}

  • Technical question, Lua version built into luahbtex, vs lua in system
    by rallg on January 17, 2026 at 7:51 pm

    This question is a matter of curiosity, rather than a problem. Just yesterday, my texlive-bin was updated. Current version says that luatex (actually luahbtex is version 1.21.0. I do not get the binaries from TeXlive: Mya Android system, with Linux-like Termux app, gets a custom-build via Termux, because the file paths (and some other things) are different. Typically, I get the texlive-bin programs a few weeks later than they are released to others. Otherwise, the non-binaries come from TeXlive. As texlive-bin was being instllaed, the Terminal told me that it would be using Lua 5.2 for support; it was already in my system. But my own documents rely on Lua features that were unavailable until Lua 5.3. Nevertheless, all good. Behold: \documentclass{article} \directlua{ if (_VERSION >= 'Lua 5.3') then texio.write('LUA GOOD') else texio.write('LUA BAD') end } \begin{document} Hello, World. \end{document} It tells me LUA GOOD, even though Lua is version 5.2. I deduce that the Lua built into luahbtex is 5.3 or later. Others have asked whether the Lua is internal or external, and it has been answered: internal. But if I try to remove Lua (any version) from my system, it cannot be removed unless I also remove texlive-bin. Evidently, the installer believes that system Lua support is needed, even though the system version and built-in version do not match. Is there a reason for that? Or is it just how the installer script was written?

  • Compilation problem with Symbolic Coordinates
    by Fabrice on January 17, 2026 at 6:31 pm

    This very simple code doesn't work, but I don't know what needs fixing. \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture} \begin{axis}[ [ xmin=0, xmax=100, y tick label style={/pgf/number format/1000 sep=}, symbolic y coords={Lecture, Jeux vidéo, Sport, Smartphone}, ytick=data ] \addplot[ xbar, fill=lightgray, ] coordinates { (10, Lecture) (50, Jeux vidéo) (30, Sport) (90, Smartphone) }; \end{axis} \end{tikzpicture} \end{document}

  • Error while running Asymptote on Windows (file ended while scanning use of \next)
    by orion2112 on January 17, 2026 at 6:00 pm

    Context All I want is to be able to plot nice 3D plots of functions of 2 variables. In another question of mine, it became clear to me that pgfplots is limiting my ability to do so. It was suggested to me to try out Asymptote. No problem, I am willing to learn... but I can't get it to compile on my setup. I've spent more time than I'm willing to admit on this and I need help. My Setup I am on Windows 11, I use TexStudio 4.9.1 and Tex Live (fresh install) and this is my Asymptote version and location C:\Users\USER>asy --version Asymptote version 3.04 [(C) 2004 Andy Hammerlindl, John C. Bowman, Tom Prince] ENABLED OPTIONS: V3D 3D vector graphics output WebGL 3D HTML rendering OpenGL 3D OpenGL rendering SSBO GLSL shader storage buffer objects GSL GNU Scientific Library (special functions) FFTW3 Fast Fourier transforms Eigen Eigenvalue library XDR External Data Representation (portable binary file format for V3D) CURL URL support LSP Language Server Protocol Readline Interactive history and editing GC Boehm garbage collector threads Render OpenGL in separate thread DISABLED OPTIONS: Sigsegv Distinguish stack overflows from segmentation faults C:\Users\ORION>where asy C:\texlive\2025\bin\windows\asy.exe I use this line for compilation: pdflatex.exe --shell-escape -synctex=1 -interaction=nonstopmode %.tex I am aware that I should be compiling 3 times (the file is called test.tex): pdflatex test.tex asy test-1.asy pdflatex test However the first pdflatex compilation fails. The problem I am trying to run the simple code: \documentclass[12pt]{article} \usepackage{asymptote} \begin{document} This is a test \begin{asy} size(5cm); draw((0,0)--(1,1)); \end{asy} \end{document} and here is a snippet of the error log (at the end): (c:/texlive/2025/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live )) \openout3 = `test-1.asy'. ) Runaway argument? ! File ended while scanning use of \next. The file I am trying to compile is called test.tex and it produces a test-1.asy file which contains the following code: \end{asy} ^ C:\Users\***\test\test-1.asy: 13.2: invalid token '\' \end{document} ^ C:\Users\***\test\test-1.asy: 14.1: invalid token '\' \end{document} ^ C:\Users\***\test\test-1.asy: 14.2: syntax error: error: could not load module 'C:\Users\***\test\test-1.asy' I find it weird that it starts with \end{asy} and I suspect this is what causes the "runaway argument" error when compiling. What I have tried Deleting all but the .tex file in the working folder and recompile. I asked Crixet about this and it told me to play around the [inline] option with \usepackage{asymptote}. It changed nothing. It asked me to look into the test.pre file, which only contains: \InputIfFileExists {\jobname -1.pre}{}{} It says there should be no space between \jobname and -1.pre and that this causes asymptote not to find the test-1.asy file. I'm not 100% about this and even if it is true, why there is a space there is beyond me. I tried running the code using a command prompt with pdflatex test.tex within the folder but get the same error, so this does not seem to be caused by TexStudio. At first I was using MikTex. I had the same issue and heard that "MikTex had an outdated Asymptote package" and "I should switch to TexLive" which I did (after having uninstalled MikTex). So it seems like the issue isn't with MikTex or Tex Live either. I have the same setup (TexStudio + MikTex) on a laptop with Kubuntu and the same code works fine. I could use this but it is not optimal for my workflow. It seems to me like other people are able to run this fine on Windows, so I don't see why I couldn't. What I'm looking for I am at a loss as to what causes this issue. Also, I'm okay with understanding Latex "code" but anything outside like running command line, changing TexStudio configuration, etc. is not something I'm experienced with. So please, if you reply, explain like I'm five, because saying things that might seem obvious like "Make sure asymptote is on path" is really not clear to me. Thanks in advanced for all the help. Edit: adding the full log This is pdfTeX, Version 3.141592653-2.6-1.40.28 (TeX Live 2025) (preloaded format=pdflatex 2026.1.17) 17 JAN 2026 14:22 entering extended mode \write18 enabled. %&-line parsing enabled. **test.tex (./test.tex LaTeX2e <2025-11-01> L3 programming layer <2025-12-29> (c:/texlive/2025/texmf-dist/tex/latex/base/article.cls Document Class: article 2025/01/22 v1.4n Standard LaTeX document class (c:/texlive/2025/texmf-dist/tex/latex/base/size12.clo File: size12.clo 2025/01/22 v1.4n Standard LaTeX file (size option) ) \c@part=\count275 \c@section=\count276 \c@subsection=\count277 \c@subsubsection=\count278 \c@paragraph=\count279 \c@subparagraph=\count280 \c@figure=\count281 \c@table=\count282 \abovecaptionskip=\skip49 \belowcaptionskip=\skip50 \bibindent=\dimen148 ) (c:/texlive/2025/texmf-dist/tex/latex/asymptote/asymptote.sty Package: asymptote 2024/02/26 v1.38 Asymptote style file for LaTeX (./test.pre) \ASYbox=\box53 \ASYdimen=\dimen149 \c@asy=\count283 \AsyStream=\write3 \AsyPreStream=\write4 (c:/texlive/2025/texmf-dist/tex/latex/graphics/keyval.sty Package: keyval 2022/05/29 v1.15 key=value parser (DPC) \KV@toks@=\toks17 ) (c:/texlive/2025/texmf-dist/tex/latex/base/ifthen.sty Package: ifthen 2024/03/16 v1.1e Standard LaTeX ifthen package (DPC) ) (c:/texlive/2025/texmf-dist/tex/latex/graphics/graphicx.sty Package: graphicx 2024/12/31 v1.2e Enhanced LaTeX Graphics (DPC,SPQR) (c:/texlive/2025/texmf-dist/tex/latex/graphics/graphics.sty Package: graphics 2024/08/06 v1.4g Standard LaTeX Graphics (DPC,SPQR) (c:/texlive/2025/texmf-dist/tex/latex/graphics/trig.sty Package: trig 2023/12/02 v1.11 sin cos tan (DPC) ) (c:/texlive/2025/texmf-dist/tex/latex/graphics-cfg/graphics.cfg File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration ) Package graphics Info: Driver file: pdftex.def on input line 106. (c:/texlive/2025/texmf-dist/tex/latex/graphics-def/pdftex.def File: pdftex.def 2025/09/29 v1.2d Graphics/color driver for pdftex )) \Gin@req@height=\dimen150 \Gin@req@width=\dimen151 ) (c:/texlive/2025/texmf-dist/tex/generic/iftex/ifpdf.sty Package: ifpdf 2019/10/25 v3.4 ifpdf legacy package. Use iftex instead. (c:/texlive/2025/texmf-dist/tex/generic/iftex/iftex.sty Package: iftex 2024/12/12 v1.0g TeX engine tests )) (c:/texlive/2025/texmf-dist/tex/generic/iftex/ifxetex.sty Package: ifxetex 2019/10/25 v0.7 ifxetex legacy package. Use iftex instead. ) (c:/texlive/2025/texmf-dist/tex/generic/catchfile/catchfile.sty Package: catchfile 2019/12/09 v1.8 Catch the contents of a file (HO) (c:/texlive/2025/texmf-dist/tex/generic/infwarerr/infwarerr.sty Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO) ) (c:/texlive/2025/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty Package: ltxcmds 2023-12-04 v1.26 LaTeX kernel commands for general use (HO) ) (c:/texlive/2025/texmf-dist/tex/generic/etexcmds/etexcmds.sty Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO) )) \openout4 = `test.pre'. ) (c:/texlive/2025/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def File: l3backend-pdftex.def 2025-10-09 L3 backend support: PDF output (pdfTeX) \l__color_backend_stack_int=\count284 ) (./test.aux) \openout1 = `test.aux'. LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3. LaTeX Font Info: ... okay on input line 3. LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3. LaTeX Font Info: ... okay on input line 3. LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3. LaTeX Font Info: ... okay on input line 3. LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3. LaTeX Font Info: ... okay on input line 3. LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 3. LaTeX Font Info: ... okay on input line 3. LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3. LaTeX Font Info: ... okay on input line 3. LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3. LaTeX Font Info: ... okay on input line 3. (c:/texlive/2025/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] \scratchcounter=\count285 \scratchdimen=\dimen152 \scratchbox=\box54 \nofMPsegments=\count286 \nofMParguments=\count287 \everyMPshowfont=\toks18 \MPscratchCnt=\count288 \MPscratchDim=\dimen153 \MPnumerator=\count289 \makeMPintoPDFobject=\count290 \everyMPtoPDFconversion=\toks19 ) (c:/texlive/2025/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4 85. (c:/texlive/2025/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv e )) \openout3 = `test-1.asy'. ) Runaway argument? ! File ended while scanning use of \next. <inserted text> \par <*> test.tex I suspect you have forgotten a `}', causing me to read past where you wanted me to stop. I'll try to recover; but if the error is serious, you'd better type `E' or `X' now and fix your file. ! Emergency stop. <*> test.tex *** (job aborted, no legal \end found) Here is how much of TeX's memory you used: 1792 strings out of 467538 29656 string characters out of 5423725 433733 words of memory out of 5000000 30710 multiletter control sequences out of 15000+600000 628019 words of font info for 41 fonts, out of 8000000 for 9000 1141 hyphenation exceptions out of 8191 72i,0n,79p,223b,66s stack positions out of 10000i,1000n,20000p,200000b,200000s ! ==> Fatal error occurred, no output PDF file produced!

  • Insert in middle blank page with 2 columns
    by miguel747 on January 17, 2026 at 5:26 pm

    I'm having trouble inserting an image (Tikz) in the middle of a document that has two columns, and the second column is blank. Any tips? I replaced the \columnbreak (which only works with multicolumns and causes the error) with \newpage in \twocolumn mode, and added another \newpage after the block to start the next section on a new page. % ============================== % Codificação e fonte % ============================== \documentclass[a4paper,9pt]{article} \usepackage{lmodern} % Usa Latin Modern como base (compatível com fontes vetoriais) \usepackage{helvet} % Usa Helvetica \renewcommand{\familydefault}{\sfdefault} % Define sans-serif como padrão % ============================== % Formatação geral da página % ============================== \usepackage{geometry} % Define margens da página \geometry{top=2cm, bottom=2.7cm, left=1cm, right=1cm, headheight=62pt} \setlength{\footskip}{50pt} % Distância do rodapé até o fim da página \setlength{\parskip}{0pt} % Espaço entre parágrafos \setlength{\parindent}{1em} % Recuo no início dos parágrafos % ============================== % Cores (xcolor deve ser carregado antes do separador) % ============================== \usepackage[table]{xcolor} \definecolor{azulpetroleo}{HTML}{084D6E} \definecolor{verdeolivaclaro}{HTML}{E8F5E9} \definecolor{brancogelo}{HTML}{F8F9FA} \definecolor{BlueGreen}{HTML}{14BCBC} \definecolor{SkyBlue}{HTML}{4285F4} \definecolor{linhaFina}{HTML}{999999} % Cinza claro para linhas finas \definecolor{linhaGrossa}{HTML}{666666} % Cinza escuro para linha grossa % Layout de colunas com separador estilizado (três linhas em tons de cinza) \setlength{\columnsep}{28pt} % Espaçamento entre colunas % Customização do separador de colunas com três linhas verticais \makeatletter \renewcommand{\@outputdblcol}{% \if@firstcolumn \global\@firstcolumnfalse \global\setbox\@leftcolumn\copy\@outputbox \splitmaxdepth\maxdimen \vbadness\maxdimen \else \global\@firstcolumntrue \setbox\@outputbox\vbox{% \hb@xt@\textwidth{% \hb@xt@\columnwidth{\box\@leftcolumn\hss}% \hfil % Separador de colunas: linha fina | linha grossa | linha fina {\color{linhaFina}\vrule width 0.4pt}% \hspace{1.5pt}% {\color{linhaGrossa}\vrule width 1.2pt}% \hspace{1.5pt}% {\color{linhaFina}\vrule width 0.4pt}% \hfil \hb@xt@\columnwidth{\box\@outputbox\hss}% }% }% \@combinedblfloats \@outputpage \begingroup \@dblfloatplacement \@startdblcolumn \@whilesw\if@fcolmade\fi{\@outputpage\@startdblcolumn}% \endgroup \fi } \makeatother % ============================== % Pacotes para matemática % ============================== \usepackage{amsmath} \usepackage{amssymb} % Fornece \checkmark e outros símbolos matemáticos \usepackage{mathtools} \everymath{\rm} % Força fonte reta em expressões matemáticas % ============================== % Tabelas % ============================== \usepackage{array} \usepackage{multirow} \usepackage{tabularx} % xcolor já foi carregado anteriormente com cores definidas % ============================== % Listas % ============================== \usepackage[inline]{enumitem} % Permite listas inline e personalização de listas % ============================== % Bibliografia % ============================== \usepackage[backend=biber, style=authoryear]{biblatex} % Geração da bibliografia \addbibresource{bibliografia.bib} % Caminho do arquivo .bib % ============================== % Cabeçalho e Rodapé % ============================== \usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} % Limpa cabeçalho e rodapé % Cabeçalho com imagem %\fancyhead[c]{ % \hspace*{-1.7em}\raisebox{0pt}{\includegraphics[height=1.11cm]{Imagens/Cabeçalho.jpeg}} %} \renewcommand{\headrulewidth}{0pt} % Remove linha de separação do cabeçalho % Defines a robust length for the footer indent %\newlength{\footerindent} %\setlength{\footerindent}{0.7\oddsidemargin} % Rodapé personalizado %\fancyfoot[l]{% % \noindent % \hspace*{\footerindent}% <-- Corrige o início da caixa com comprimento pré-calculado % \colorbox{azulpetroleo}{ % fundo azul % \parbox{\paperwidth}{ % caixa que ocupa toda a largura do papel % \vspace{7pt} % \hspace{3em}\textcolor{white}{\textbf{\large SIMULADO 01 -- CAIXA}}\\[-3em] % % \hspace{3em}\textcolor{white}{Engenharia Elétrica} % \hfill % \includegraphics[height=1.4cm]{Imagens/Projeto_100_Aprovação.png} % \vspace{9pt} % } % } %} \fancyfoot[C]{% \raisebox{8pt}{ \tikz[baseline=(char.base), yshift=15pt]\node[ draw=white, fill=azulpetroleo, text=white, line width=1pt, inner sep=6pt, minimum width=1.5em, minimum height=1.5em ](char){\thepage}; } } % ============================== % Outros pacotes úteis % ============================== \usepackage{setspace} % Permite configurar espaçamento entre linhas \usepackage{tikz} % Criação de gráficos vetoriais \usepackage{circuitikz} % Diagramas eletricos/eletroeletronicos \usepackage[most]{tcolorbox} % Caixas coloridas avançadas \usepackage{eso-pic} % Adição de elementos na página (como molduras) \usepackage{lastpage} % Conta número total de páginas \usepackage[switch*]{lineno} % Numeração de linhas na margem externa (não reduz largura do texto) % ============================== % Configuração de numeração de linhas nos textos % ============================== \renewcommand\linenumberfont{\normalfont\fontsize{7}{9}\selectfont\itshape\bfseries} % Números em itálico e negrito, tamanho 7 \setlength\linenumbersep{-20pt} % Espaço entre número e margem do texto \setlength{\linenumberwidth}{2em} % Largura reservada para os números % Redefinição para alinhar números à esquerda e exibir apenas múltiplos de 5 (exceto 0) \makeatletter \renewcommand\makeLineNumber{% % Verifica se o número da linha é múltiplo de 5 e diferente de 0 \@tempcnta=\value{linenumber}% \divide\@tempcnta by 5\relax \multiply\@tempcnta by 5\relax \ifnum\@tempcnta=\value{linenumber}% \ifnum\value{linenumber}>0% \hss\makebox[\linenumberwidth][l]{\linenumberfont\thelinenumber}\hskip\linenumbersep \fi \fi } \makeatother % Ambiente para textos com numeração de linhas (reinicia contagem automaticamente) % Exibe apenas múltiplos de 5 (5, 10, 15, 20...), omitindo o número 0 \newenvironment{textonumerado}{% \par \setcounter{linenumber}{0}% \begin{linenumbers}% }{% \end{linenumbers}% \par } % Redefinição do flushright para desativar numeração de linhas (usado nas referências) \let\oldflushright\flushright \let\oldendflushright\endflushright \renewenvironment{flushright}{% \nolinenumbers \oldflushright }{% \oldendflushright } \usepackage{float} % mater a imagem onde foi colocada \usepackage{pdfpages} % Inserir PDFs externos \usepackage{pifont} % Símbolos especiais como \ding{} % ============================== % Comandos para questões % ============================== % Comando para inserir questão com alternativas maiusculas (A) \newcommand{\questaoV}[2]{ \item #1 \begin{enumerate}[label=(\Alph*),itemsep=0.3em] #2 \end{enumerate} } \newcommand{\questaoVtexto}[4]{ \item #1 \vspace{1em} #2 \vspace{1em} #3 \begin{enumerate}[label=(\Alph*),itemsep=0.3em] #4 \end{enumerate} } %Questoes com alternativas na Horizontal \newcommand{\questaoH}[2]{ \item #1 \begin{enumerate*}[label=(\Alph*),itemsep=0.3em] #2 \end{enumerate*} } %Novo comando para questões com afirmativas e alternativas \newcommand{\questaoComAfirmativas}[4]{ \item #1 \begin{enumerate}[label=\Roman*.,itemsep=0.3em] #2 \end{enumerate} #3 %comando to da questão \begin{enumerate}[label=(\Alph*),itemsep=0.3em] #4 \end{enumerate} } % ============================== % Ambiente Gabarito Box % ============================== \newtcolorbox{gabaritobox}{ enhanced, breakable, colback=brancogelo, colframe=brancogelo, arc=2mm, boxrule=0pt, left=6pt, right=6pt, top=6pt, bottom=6pt, fontupper=\itshape, colupper=SkyBlue, before upper={\noindent\raisebox{-0.3\height}{\includegraphics[width=16pt]{Imagens/gabarito.png}}\hspace{0.3em}\textbf{\normalfont COMENTÁRIOS:}\hspace{0.5em}}, overlay unbroken and first={} } % ============================== % Hyperref (deve ser carregado por último) % ============================== \usepackage[bookmarks=true,bookmarksopen=true,bookmarksopenlevel=1,colorlinks=true,linkcolor=black,urlcolor=blue,citecolor=black]{hyperref} % Necessário para \phantomsection e links \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% NOÇÕES DE PROBABILIDADE E ESTATÍSTICA %%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newpage \begin{center} \subsection*{NOÇÕES DE PROBABILIDADE E ESTATÍSTICA} \end{center} \begin{enumerate}[leftmargin=*,label=\textbf{\arabic*.},itemsep=0.5em, resume=lista] % =============================================== % QUESTÃO 26 - Telemetria e Esperança Condicional % =============================================== \questaoV{Em um sistema de telemetria de uma subestação, dois sensores binários são monitorados a cada instante: \begin{itemize} \item $X$: indica se houve detecção de evento (0 = não, 1 = sim); \item $Y$: indica se um alarme foi acionado (0 = não, 1 = sim). \end{itemize} As probabilidades conjuntas observadas são: \begin{align*} P(X=0 \text{ e } Y=0) &= \frac{1}{4} \\ P(X=1 \text{ e } Y=0) &= \frac{1}{8} \\ P(X=0 \text{ e } Y=1) &= \frac{1}{2} \\ P(X=1 \text{ e } Y=1) &= \frac{1}{8} \end{align*} Com base nessas informações, dado que $X=1$, o valor esperado de $Y$ é:}{ \item $\dfrac{1}{4}$ \item $\dfrac{1}{2}$ \item $\dfrac{1}{8}$ \item $\dfrac{1}{3}$ \item $\dfrac{3}{4}$ } % =============================================== % QUEST�O 27 - Media Geometrica % =============================================== \questaoV{Quando tres numeros reais, positivos e nao nulos formam uma progressao geometrica, dizemos que o termo do meio corresponde a media geometrica dos outros dois. Desse modo, qual e a media geometrica entre 28 e 252?}{ \item 84 \item 168 \item 882 \item 1.764 \item 3.528 } % =============================================== % QUESTÃO 28 - Análise de Dados do ENADE % =============================================== \end{enumerate} % Temporariamente muda para uma coluna para acomodar a tabela larga da Q28 \onecolumn \begin{enumerate}[leftmargin=*,label=\textbf{\arabic*.},itemsep=0.5em, resume=lista] \questaoV{As questões do questionário socioeconômico foram tabuladas segundo as respostas dos ingressantes e dos concluintes e também segundo os dois grupos extremos (inferior e superior) de desempenho dos alunos da área no ENADE 2006. Esses grupos foram definidos pelos percentis de ordem 25 (P25) e 75 (P75). Os resultados relativos ao número de horas de estudo encontram-se na tabela a seguir. \textbf{Pergunta:} \textit{Quantas horas por semana, aproximadamente, você dedica/dedicou aos estudos, excetuando as horas de aula?} \begin{center} \begin{tabular}{|l|c|c|c|c|c|c|} \hline \textbf{Horas de estudo} & \multicolumn{3}{c|}{\textbf{Ingressantes}} & \multicolumn{3}{c|}{\textbf{Concluintes}} \\ \textbf{por semana} & P25 & P75 & Total & P25 & P75 & Total \\ \hline Nenhuma & 9,7\% & 4,6\% & 7,0\% & 12,7\% & 6,1\% & 9,3\% \\ \hline Uma a duas & 47,2\% & 29,7\% & 40,1\% & 46,8\% & 32,6\% & 40,4\% \\ \hline Três a cinco & 27,9\% & 35,1\% & 31,5\% & 25,7\% & 32,0\% & 29,8\% \\ \hline Seis a oito & 8,2\% & 15,6\% & 11,6\% & 7,9\% & 13,9\% & 10,7\% \\ \hline Mais de oito & 6,4\% & 14,7\% & 9,4\% & 6,3\% & 15,1\% & 9,5\% \\ \hline Sem informação & 0,6\% & 0,3\% & 0,4\% & 0,6\% & 0,3\% & 0,3\% \\ \hline \textbf{Amostra} & \multicolumn{3}{c|}{\textbf{38461}} & \multicolumn{3}{c|}{\textbf{27608}} \\ \hline \end{tabular} \end{center} Analisando-se as informações, conclui-se que: \textbf{I} -- a proporção de alunos que não estudam ou estudam no máximo duas horas por semana é maior no grupo de concluintes com desempenho inferior na prova; \textbf{II} -- pelo menos 12.000 alunos da área estudam mais de oito horas por semana; \textbf{III} -- a maioria dos alunos com desempenho superior, nos dois grupos, estuda de três a oito horas por semana; \textbf{IV} -- mais de 60,0\% dos alunos concluintes com desempenho superior na prova estudam, no mínimo, três horas por semana. Está(ão) correta(s) APENAS a(s) informação(ões):}{ \item I \item III \item I e IV \item I, II e IV \item II, III e IV } \end{enumerate} % Área de rascunho \vspace{0.5cm} \begin{center} \begin{tikzpicture} \node[opacity=0.3, rotate=45, scale=4, text=gray] {RASCUNHO}; \end{tikzpicture} \end{center} % Retorna ao layout de duas colunas \twocolumn \begin{enumerate}[leftmargin=*,label=\textbf{\arabic*.},itemsep=0.5em, resume=lista] % =============================================== % QUESTÃO 29 - Probabilidade sem Reposição % =============================================== \questaoV{Em um treinamento operacional de uma agência bancária, a coordenação prepara um conjunto com 52 cartões, todos bem embaralhados, cada um contendo o nome de uma operação. Dentre esses cartões, 12 são de operações consideradas ``prioritárias'', distribuídas igualmente entre: \begin{itemize} \item Transferência (TED) \item Pix \item Cartão de Crédito \end{itemize} (isto é, 4 cartões de cada uma dessas operações, totalizando 12 cartões prioritários). Retiram-se 4 cartões ao acaso, sem reposição. Qual é a probabilidade de que todos os 4 cartões retirados sejam cartões prioritários (TED, Pix ou Cartão de Crédito)?}{ \item $\dfrac{141}{54145}$ \item $\dfrac{325}{62522}$ \item $\dfrac{82}{43131}$ \item $\dfrac{99}{54145}$ \item $\dfrac{11}{54145}$ } % =============================================== % QUESTÃO 30 - Medidas Estatísticas % =============================================== \questaoV{A tabela a seguir apresenta a distribuição dos clientes de uma determinada agência bancária classificados segundo o perfil do investidor em: conservadores, moderados e arrojados. \begin{center} \begin{tabular}{|l|r|} \hline \textbf{Classificação dos clientes} & \textbf{Frequência absoluta} \\ \hline \textbf{Total} & \textbf{11.000} \\ \hline Conservadores & 3.300 \\ \hline Moderados & 5.400 \\ \hline Arrojados & 2.300 \\ \hline \end{tabular} \end{center} Considere as medidas estatísticas: média, moda, mediana, variância e desvio padrão. Para análise da classificação dos clientes, é possível determinar a:}{ \item moda, apenas. \item média e a mediana, apenas. \item média, a moda e a mediana, apenas. \item média, a variância e o desvio padrão, apenas. \item média, a moda, a mediana, a variância e o desvio padrão. } \end{enumerate} \newpage % Preenche o restante da segunda coluna com marca d'água \vfill \newpage \begin{center} \begin{tikzpicture} \node[opacity=0.3, rotate=45, scale=4, text=gray] {RASCUNHO}; \end{tikzpicture} \end{center} \vfill \end{document}

  • Exam Class (Hirschhorn) has different Itemize Spacings for the solution and the solutionbox Environments
    by 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

  • How can I define a custom listings language for MusicBrainz Picard scripts that matches the editor’s syntax highlighting
    by Marco Moldenhauer on January 17, 2026 at 6:57 am

    I’m trying to define a custom language in LaTeX using \lstdefinelanguage so that keywords and variables in MusicBrainz Picard scripts are highlighted similarly to Picard’s built-in script editor (see MusicBrainz Picard Script Reference below). Here’s what I have so far: My Code \documentclass{article} \usepackage{listings} \usepackage{xcolor} \lstdefinelanguage{PicardScript}{ sensitive=true, morecomment=[l]{\#}, morestring=[b]", morekeywords=[1]{% $if,$if2,$left,$right,$num,$replace, $gt,$lt,$eq,$ne,$and,$or,$not,$len, $lower,$upper }, morekeywords=[2]{% \%artist\%,\%albumartist\%,\%album\%,\%title\%, \%date\%,\%originaldate\%,\%tracknumber\%, \%discnumber\%,\%totaldiscs\% }, keywordstyle=[1]\color{blue}\bfseries, keywordstyle=[2]\color{orange}, stringstyle=\color{red}, identifierstyle=\color{black}, commentstyle=\color{gray}\itshape } \lstset{ basicstyle=\ttfamily\tiny, numbers=left, numberstyle=\tiny\color{gray}, stepnumber=1, numbersep=5pt, showstringspaces=false, breaklines=true, tabsize=4, frame=single, commentstyle=\color{gray}\itshape } \begin{document} \begin{lstlisting}[language=PicardScript] $if2(%albumartist%,%artist%)/ ($left($if2(%originaldate%,%date%),4)) $replace(%album%,:,)/ $if($gt(%totaldiscs%,1),$num(%discnumber%,2)-)$num(%tracknumber%,2) - %artist% - %title% \end{lstlisting} \end{document} My Output: I would like the LaTeX output to match the coloring style of the Picard script editor. How can I modify my \lstdefinelanguage definition to better replicate the Picard script editor’s keyword coloring? MusicBrainz Picard Script Reference: Link: https://picard.musicbrainz.org/

  • MTPro-II differences under lualatex vs pdflatex/xelatex
    by Knudsen on January 17, 2026 at 4:31 am

    The following MWE produces a nice square root sign provided by MTPro-II \documentclass{report} \usepackage{amsmath} \usepackage{mtpro2} \begin{document} \[ \SQRT{\begin{pmatrix} 1 & 0 & 0 \\ 0 & 4 & 0 \\ 0 & 0 & 9 \end{pmatrix}} \] \end{document} This works fine under pdflatex and xelatex producing the nice slanted surd portion of the square root sign But when processed with lualatex it goes back to the old CM square root sign Can anyone shed light on what is going on?

  • 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😊.

  • Drawing a porous sandwich beam
    by 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:

  • Primes in Latex
    by 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 diagram
    by 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}