• Raise subscript position in lualatex
    by Alexander Voigt on April 27, 2026 at 8:25 am

    I am typesetting the following matrix equation (MWE): \documentclass[preview]{standalone} \usepackage{iftex} \ifLuaTeX \usepackage{unicode-math} \else \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{amsmath} \fi \begin{document} \[ \begin{pmatrix} \underline{v}_1^T \\ \underline{v}_3^T \\ \underline{v}_3^T \end{pmatrix} = \begin{pmatrix} v_{11} & v_{12} & v_{13} \\ v_{21} & v_{22} & v_{23} \\ v_{31} & v_{32} & v_{33} \end{pmatrix} \] \end{document} When I compile with pdflatex, the matrix elements on the l.h.s. look good to me. In particular, both the subscripts (indices) and the superscripts (T) are properly set and readable: However, when I compile with lualatex, the subscripts overlap with the succeeding line: I've also created a gif for a better comparison: My question is: How can I avoid the overlap? (My wish would be to consistently raise the subscripts. I'd like to avoid increasing the row distance, because then the rows on the l.h.s. would not properly align with the rows on the r.h.s.)

  • How can we obtain a smoother sphere when cutting it with a plane and moving the cut portion?
    by minthao_2011 on April 26, 2026 at 11:11 am

    I am using this code in luadraw to cut a sphere with a plane and move one of the cut parts to another position. Currently, the surface of the sphere is not really smooth. If I increase the number in this line local S = sphere(Origin, R, 60, 60) to a larger value, the compilation becomes slower. How can I make the sphere smoother? \documentclass[border=5pt]{standalone} \usepackage[svgnames]{xcolor} \usepackage[3d]{luadraw} \begin{document} \begin{luadraw}{name=sphere_clip3d_fixed} local R = 3 local g = graph3d:new{window={-R-2, R+1, -R-1, R}, viewdir={110, 60}, size={10, 10}} Hiddenlinestyle = "dashed" local S = sphere(Origin, R, 60, 60) local Box = parallelep(M(-5,-5,1.5), 10*vecI, 10*vecJ, 10*vecK) local S_top = clip3d(S, Box) local S_bottom = clip3d(S, Box, true) local vector = 2*vecK + 5*vecJ local S_top_shifted = shift3d(S_top, vector) local I_bottom = border(S_bottom) local I_top_shifted = border(S_top_shifted) g:Dscene3d( g:addFacet(S_bottom, {draw="ball color=orange", color="orange", backcull=true}), g:addFacet(S_top_shifted, {draw="ball color=orange", color="orange", backcull=true}), g:addPolyline(I_bottom, {color="Navy", hidden=true}), g:addPolyline(I_top_shifted, {color="Navy", hidden=true}) ) g:Show() \end{luadraw} \end{document}

  • Changing greeks (in math mode) with XeLaTeX
    by Ryan Kong on April 26, 2026 at 7:22 am

    I want to change the greek font into STEP while keeping all other math font in TeX Gyre Termes Math and text font in Times New Roman. The following is my MWE: %! TEX program = xelatex \documentclass{article} \usepackage{amsmath,amssymb,amsthm} \usepackage{fontspec} \usepackage{unicode-math} \setmainfont{Times New Roman} \setmathfont{TeX Gyre Termes Math} \setmathfont{STEP}[ range={upgreek, uprightgreek, itgreek, italicgreek}, script=greek ] \begin{document} $\alpha \beta \Gamma \Delta$\\ $f(x) = x^2$ \end{document} It gives me some error messages: undefined Transcript written on test.log. Missing number, treated as zero. <to be read again> Use of \??? doesn't match its definition. <argument> \??? I don't know where went wrong. I downloaded all the fonts I need, and I can run the code if I remove the code: \setmathfont{STEP}[ range={upgreek, uprightgreek, itgreek, italicgreek}, script=greek ] but it gives me this instead. Any help would be much appreciated.

  • why \begin{align*}..\end{align*} spacing is different inside tikz Matrix node than outside?
    by Nasser on April 26, 2026 at 4:33 am

    I am learning how to use tikz Matrix to layout few things. Notice that inside tikz matrix node, the alignment is not the same as outside tikz using standard &= for align math environment. I had to to put align environment inside a minipage to make it work inside tikz matrix node. It will not let me just use align directly since not paragraph mode. But the issue is the spacing between left side of &= and right side is different than outside tikz. \documentclass[12pt,varwidth]{standalone} %need varwidth to use align inside standalon \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \fbox{\begin{minipage}{1.5in} \vspace{0pt} % Fixes top spacing issues \noindent % Ensures no paragraph indentation {\small All plots used the same initial conditions \begin{align*} x(0) &=1\\ x'(0) &=1\\ \end{align*} } \end{minipage} } \begin{tikzpicture} \matrix (m) [matrix of math nodes, nodes={anchor=center}, row sep=3.5em, column sep=2.5em, nodes in empty cells, draw] { 1& 2& \begin{minipage}{1.5in} \vspace{0pt} % Fixes top spacing issues \noindent % Ensures no paragraph indentation {\small All plots used the same initial conditions \begin{align*} x(0) &=1\\ x'(0) &=1\\ \end{align*} } \end{minipage} &4 \\ 5& 6 & 7 & 8 \\ }; \foreach \i in {1,2,3,4} \foreach \j in {1,2} \draw [help lines] (m-\j-\i.south west) rectangle (m-\j-\i.north east); \end{tikzpicture} \end{document} Compiled with lualatex gives lualatex, TL 2026

  • How to fully center text inside tikz Matrix node, which spans multiple columns?
    by Nasser on April 26, 2026 at 3:02 am

    I need to make a node in tikz matrix which spans multiple columns. After much struggle and trial and error, this is the result \documentclass[12pt]{standalone} \usepackage{tikz} \usetikzlibrary{positioning,arrows,chains,matrix,scopes,fit} \usetikzlibrary{backgrounds} \begin{document} \begin{tikzpicture} \matrix (m) [matrix of math nodes, nodes={anchor=center}, row sep=3.5em, column sep=2.5em, nodes in empty cells, draw] {1 & 2 & 3 & 4 \\ 5 & & & \\ 9 & 10 & 11 & 12\\ }; \node[fit=(m-2-2)(m-2-4),align=center,text centered,draw,fill=yellow]{spans cols 2 to 4}; \end{tikzpicture} \end{document} Compiled using lualatex gives Which is what I want, except I do not know how to make the text "spans cols 2 to 4" to be fully centered inside the node that spans the columns. I tried adding align=center and text centered as you see, but this had no effect on vertical centering inside the node. What is correct way to do this? Now the baseline as you see of the text inside, is not aligned with the baseline of the other nodes in the tikz matrix. TL 2026

  • Linebreak: Strange word protrusion into the margin without hyphenating word "impedance" interacted with `microtype`?
    by Explorer on April 26, 2026 at 1:58 am

    Claim: I believe that the code example could be simplified further. However, I don't find it easy to construct... : Here below is the original case: % lualatex \documentclass[zihao=-4,fontset=none]{ctexbook} \RequirePackage[ papersize={210mm,297mm}, margin=25mm,showframe, ]{geometry} \RequirePackage{enumitem} \usepackage{txfonts} \usepackage[T1]{fontenc} \begin{document} \begin{enumerate}[label={[}\arabic*{]}, labelindent=\parindent, leftmargin=*] \item Tao Y, \textbf{Liu H}, Wang X, et al. Probabilistically Informed Motion Primitives for Impedance Control in Contact-Rich Manipulation Tasks[J]. xxxx. \end{enumerate} \end{document} If we add microtype, with lualatex, it works: % lualatex \documentclass[zihao=-4,fontset=none]{ctexbook} \RequirePackage[ papersize={210mm,297mm}, margin=25mm,showframe ]{geometry} \RequirePackage{enumitem} %%%%%%%%% \usepackage{txfonts} \usepackage[T1]{fontenc} \usepackage{microtype} \begin{document} \begin{enumerate}[label={[}\arabic*{]}, labelindent=\parindent, leftmargin=*] \item Tao Y, \textbf{Liu H}, Wang X, et al. Probabilistically Informed Motion Primitives for Impedance Control in Contact-Rich Manipulation Tasks[J]. xxxx. \end{enumerate} \end{document} But with xelatex, it doesn't: I found it hard to remove the \documentclass[zihao=-4]{ctexbook} dependency to simplifiy the code, which change fontsize internally... Learning from this link, there are many better alternatives to txfonts: \usepackage{newtxtext} \usepackage{tgtermes} \usepackage[T1]{fontenc} \setmainfont{Times New Roman} \setmainfont{TeX Gyre Termes} But all confront with the word "Impedance" protrusion without microtype... My questions are: What caused the word "Impedance" protrusion here? Is this the expected bahavior? And is microtype the recommended package to tweak here (while failed with xelatex😔)?

  • Images plus spacer to fit exactly text width
    by user1850133 on April 25, 2026 at 11:34 am

    How can I fill horizontally the whole space with e.g. 2 images and a spacer in between? Here's my try using \textwidth, but it crosses the text area. \documentclass[a4paper]{article} \usepackage{graphicx} \usepackage[showframe]{geometry} \setlength\parindent{0pt} \begin{document} \includegraphics[width=.45\textwidth]{example-image-9x16} \hspace{.1\textwidth} \includegraphics[width=.45\textwidth]{example-image-9x16} \end{document}

  • How can I use Lua syntax inside a pgfkeys key, and load that from Lua so I can later print it's descendents to TeX?
    by Jasper on April 25, 2026 at 9:34 am

    How can I use Lua syntax inside a pgfkeys key, and load that from Lua so I can later print it's descendents to TeX? This MWE looks ridiculous, but don't laugh! It's actually designed to show the type of behaviour I want to enable. That is, I want to have lua syntax highlighting in certain keys when I set them, and lua category codes too. I think it would be a really beautiful thing. \documentclass{article} \usepackage{jasper} \begin{document} \setobject[nice = { -- this is some lua syntax local with = "a \\par!" local wow = "!" -- I want to use the % operator too local test = 5 % 2 tex.sprint(test) -- blah return 7 }] \end{document} \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesExplPackage{jasper}{1994/04/05}{v1.0.0}{ LuaLaTeX package for a question about pgfkeys and Lua. } \RequirePackage{tikz} \tikzset{ /jasper/.is~family ,/jasper/.cd ,nice/.code = {\protected@edef\jasper@nice{#1}} } \lua_load_module:n { George } \NewDocumentCommand { \setobject } {o} { \group_begin: \tikzset{ /jasper/.search~also = {/tikz} ,/jasper/.cd ,#1 } \__jasper_setobject: \group_end: } local function register_tex_cmd(name, func, args, protected) name = "__jasper_" .. name .. ":" .. ("n"):rep(#args) local scanners = {} for _, arg in ipairs(args) do scanners[#scanners+1] = token['scan_' .. arg] end local scanning_func = function() local values = {} for _, scanner in ipairs(scanners) do values[#values+1] = scanner() end func(table.unpack(values)) end local index = luatexbase.new_luafunction(name) lua.get_functions_table()[index] = scanning_func if protected then token.set_lua(name, index, "protected") else token.set_lua(name, index) end end local function body_expression(str) return load(str, "expression", "t", _G)() end local function set_object(hash) local object = body_expression(hash.object) local name = hash.name lua_tikz3dtools.math[name] = object end register_tex_cmd("setobject", function() set_object{ nice = token.get_macro("jasper@nice"), } end, { })

  • How to draw steographically projected Clifford parallels?
    by Jasper on April 25, 2026 at 2:11 am

    I want to draw that cool diagram by Penrose in twistor theor; it's supposed to be composed of steographically projected Clifford parallels. credit: https://www.eurekalert.org/multimedia/928836 Not this Clifford: But rather this one: I attempted to try it myself, as I am fond of stereographic projection. However, I have never studied Clifford tori. I have no basis to check is my work is actually based on Clifford parallels. I only made tori using regular old stereographic projection. I don't know if this is right. This is the MWE I made. It uses my package, which can be downloaded from github. \documentclass[tikz,border=1cm]{standalone} \usepackage{lua-tikz3dtools} % https://github.com/Pseudonym321/TikZ-Animations/tree/master1/TikZ/lua-tikz3dtools \begin{document} \foreach \CCC in {5,10,...,25} { \begin{tikzpicture} \useasboundingbox (-5,-5) rectangle (5,5); \appendlight[v = {return Vector:new{1, 1, 1 , 1}}] \def\SSS{3} \foreach \AAA in {0,30,60} { \pgfmathsetmacro{\AAA}{\AAA+\CCC} \setobject[ name=a,object={\AAA*pi/180} ] \setobject[ name=R, object={1/cos(a)} ] \setobject[ name=r, object={sqrt(abs(1/cos(a)^2)-abs(cos(a)))} ] \setobject[ name=view, object = {Matrix.zyzrotation3(pi/2, pi/3, pi/6)} ] \pgfmathtruncatemacro{\BBB}{((\AAA-10)*10/7)} \appendsurface[ ustart={pi/2}, ustop={-pi}, usamples= 20, vstart=0, vstop=tau, vsamples= 50, transformation = {return view}, v = { return Vector.hsphere3(u, v, r) :hadd(Vector:new{R*cos(u), R*sin(u), 0, 1}) }, filter = { local M = A:hadd(B):hadd(C):hscale(1/3):multiply(view:inverse()) return abs(M[1]) < \SSS.001 and abs(M[2]) < \SSS.001 and abs(M[3]) < \SSS.001 }, fill options = {fill={gray!\BBB!black!50!ltdtbrightness},fill opacity = 1}, curve = { local segments = {} local domain_origin = pi/2 local branches = 7 local samples_per_branch = 40 local samples = branches*samples_per_branch local step = tau/samples local function append_segment(s0, s1) if s1 <= s0 then return end local wrap = floor(branches*s0/tau + 1e-9) local u0 = domain_origin - s0 local u1 = domain_origin - s1 local v0 = branches*s0 - wrap*tau local v1 = branches*s1 - wrap*tau table.insert(segments, { Vector:new{u0, v0}, Vector:new{u1, v1}, drawoptions = "draw = green!50!black, thick" }) end for i = 0, samples - 1 do local s0 = i*step local s1 = s0 + step local wrap0 = floor(branches*s0/tau + 1e-9) local wrap1 = floor(branches*s1/tau + 1e-9) if wrap0 == wrap1 then append_segment(s0, s1) else local seam = (wrap0 + 1)*tau/branches append_segment(s0, seam) append_segment(seam, s1) end end return segments } ] } % ends foreach \appendsolid[ ustart=-\SSS, ustop=\SSS, usamples= \SSS, vstart=-\SSS, vstop=\SSS, vsamples= \SSS, wstart=-\SSS, wstop=\SSS, wsamples= \SSS, transformation = {return view}, filter = {return false}, v = {return Vector:new{u, v, w, 1}} ] \displaysimplices \end{tikzpicture}} % ends \CCC \end{document}

  • Improved visualization of the domains of integration in ℝ³
    by Sebastiano on April 24, 2026 at 9:26 pm

    Before of this question, I would like to thank the authors of the answers and everyone who appreciated my question. I had previously created these two figures related to two triple integrals. Is there a better way to improve their presentation and make them clearer and more visually appealing? T={(x, y, z) ∈ ℝ³: (x²+y²)¹/² ≤ z ≤ 1}. \documentclass[12pt]{article} \usepackage{tikz,tikz-3dplot} \begin{document} \begin{center} \tdplotsetmaincoords{60}{130} \begin{tikzpicture}[tdplot_main_coords,scale=3] \pgfmathsetmacro{\h}{0.6} \pgfmathsetmacro{\raggio}{\h} \draw[thick,->] (0,0,0) -- (1.5,0,0) node [below left] {\footnotesize$x$}; \draw[dashed] (0,0,0) -- (-1.5,0,0); \draw[thick,->] (0,0,0) -- (0,1.5,0) node [right] {\footnotesize$y$}; \draw[dashed] (0,0,0) -- (0,-1.5,0); \draw[thick,->] (0,0,1.0) -- (0,0,1.5) node [above] {\footnotesize$z$}; \draw[dashed] (0,0,0) -- (0,0,1.0); \foreach \altura in {0.01,0.02,...,1.0}{ \draw[cyan,opacity=0.5] plot[domain=0:2*pi,smooth,variable=\t] ({\altura*cos(\t r)},{\altura*sin(\t r)},{\altura}); } \draw[blue,thick,fill=brown!50,opacity=0.6] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},{\h}); \draw[dashed,fill=yellow,opacity=0.4] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},0); \foreach \t in {0,10,30,60,90,120,150,250,280,310}{ \draw[black,dashed,thin,opacity=0.7] ({\raggio*cos(\t)},{\raggio*sin(\t)},{\h}) -- ({\raggio*cos(\t)},{\raggio*sin(\t)},0); } \fill[gray,opacity=0.1] (-1.2,-1.2,\h) -- (1.2,-1.2,\h) -- (1.2,1.2,\h) -- (-1.2,1.2,\h) -- cycle; \draw[red,very thick] (0,0,\h) -- (0,\raggio,\h); \node at (0,1.5,\h) {\small $z=h$}; \node at (0,0.5,0.75) {\small $z$}; \node at (0,0.25,-0.35) {\small $T(z=0)$}; \node at (0,.75,1.3) {\small $T(z=h)=T(z)$}; \end{tikzpicture} \end{center} \end{document} C= {(x,y,z)∈ ℝ³: z∈ [0, 2], x²+ y²≤ z} \documentclass[12pt]{article} \usepackage{tikz,tikz-3dplot} \begin{document} \begin{center} \tdplotsetmaincoords{70}{130} \begin{tikzpicture}[tdplot_main_coords,scale=2.5] \pgfmathsetmacro{\h}{.6} \pgfmathsetmacro{\raggio}{sqrt(\h)} \draw[thick,->] (0,0,0) -- (1.5,0,0) node [below left] {$x$}; \draw[thick,->] (0,0,0) -- (0,1.5,0) node [right] {$y$}; \draw[thick,->] (0,0,0) -- (0,0,1.5) node [above] {$z$}; \draw[red,very thick] plot[domain=-1:1,smooth,variable=\t] (0,{\t},{\t*\t}); \draw[blue,fill=yellow,opacity=0.4] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},{\h}); \draw[fill=yellow,dashed,opacity=0.5] plot[domain=0:2*pi,smooth,variable=\t] ({\raggio*cos(\t r)},{\raggio*sin(\t r)},{0}) node [above] {\tiny $C(z)$}; \foreach \t in {0,10,...,350}{ \draw[gray, dashed, thin,opacity=0.4] ({\raggio*cos(\t)},{\raggio*sin(\t)},{\h}) -- ({\raggio*cos(\t)},{\raggio*sin(\t)},0); } \foreach \altura in {0.0125,0.025,...,1.0}{ \pgfmathsetmacro{\radio}{sqrt(\altura)} \draw[cyan,thick,opacity=0.5] plot[domain=0:2*pi,smooth,variable=\t] ({\radio*cos(\t r)},{\radio*sin(\t r)},{\altura}); } \fill[orange!30,opacity=0.4] (-1,-1,\h) -- (1,-1,\h) -- (1,1,\h) -- (-1,1,\h) -- cycle; \draw[blue,very thick] (0,0,\h) -- (0,{\raggio},\h); \node[black, above right] at (0,{\raggio/2},\h) {\tiny $\sqrt{z}$}; \draw[blue,fill=yellow,dotted,thick,opacity=0.4] plot[domain=0:360,smooth,variable=\t] ({\raggio*cos(\t)},{\raggio*sin(\t)},{\h}); \draw[blue!80,thick] plot[domain=0:2*pi,smooth,variable=\t] ({cos(\t r)},{sin(\t r)},{1.0}); \end{tikzpicture} \end{center} \end{document}

  • Ungrouped alternatives to \foreach which are still canonical to use with tikz
    by Jasper on April 24, 2026 at 7:51 pm

    Are there ungrouped alternatives to \foreach which are still canonical to use with tikz? I need to define a color in a loop and use it outside. Maybe expl3? \documentclass{article} \usepackage{pgffor,xcolor} \begin{document} \foreach \i in {1,2} {\colorlet{blah}{blue!\i}} \textcolor{blah}{blah} \end{document}

  • Tikz pie chart with units
    by Thomas on April 24, 2026 at 1:07 pm

    I have a pie chart representing a distribution of hours, and I'm using the option sum=auto to display the chat by these values. But I'd like to add the unit of the values inside the plot. If I type 12~h/Maths it raises error because LaTeX tries to compute the percentages. How could I achieve it ? \documentclass{article} \usepackage{pgf-pie} \begin{document} \begin{tikzpicture} \pie[sum = auto]{ 12/Maths, 9/Physique-Chimie, 2/Informatique, 2/TIPE, 2/Français } \end{tikzpicture} \end{document}

  • European Computer Modern-like font that allows for bold italic smallcaps (textsc)?
    by canIchangethis on April 24, 2026 at 8:40 am

    I would love to have bold, italicised small caps in my LaTeX document, using T1 encoding and, ideally, a font as close as possible to European Computer Modern. And I would like to only redefine \textbf{\textit{\textsc{}}} so that I can use smallcaps in italic and bold from another font. Related, I found this older question: https://tex.stackexchange.com/a/746482/114622 Thus, this is my MWE, which doesn't work, as in, it produces the warning: Font shape `T1/cmr/bx/scit' undefined \documentclass{article} \usepackage[T1]{fontenc} begin{document} \begin{center} \textbf{\textit{\textsc{my text}}} \end{center} \end{document}

  • pgf-PeriodicTable: produce a gap at La and Ac
    by cis on April 24, 2026 at 1:36 am

    How could I create a gap here (as seen sometimes)? \documentclass[landscape]{article} \usepackage[margin=11mm]{geometry} \usepackage{pgf-PeriodicTable} \tikzset{every picture/.append style={remember picture}} \begin{document} \pgfPT[ show title=false, show legend=false, IUPAC=false,% puts La and Ac above ] % Test \begin{tikzpicture}[remember picture, overlay] \node[fill, inner sep=0pt, minimum size=2mm, cyan, text=red] at (3.center) {UL}; \end{tikzpicture} \end{document}

  • Is \textit now long, instead of short?
    by rallg on April 24, 2026 at 1:25 am

    In the past, something such as \textit{this\par that} would throw an error, because the \textit command was "short" (it could not span paragraphs). But I now see (TeXlive 2026) that is is "long" (can span paragraphs). This is verified by inspecting code in file latex.ltx even though that file is not necessarily loaded. Even AI did not know that! Or did I hack something, and forgot about it? EDIT: When I first asked the question, it was with the assumption that something had changed in TeXlive 2026. No, as the answers and comments reveal. Rather, I had not noticed this before. That is, I knew that \textit could not span paragraphs, but had not seen its full definition. MWE: \documentclass{article} \show\textit \expandafter\show\csname textit \endcsname \begin{document} \textit{Hello \par World.} Goodbye, cruel world! \end{document} That produces the following console output (simplified): > \textit=macro: ->\protect \textit . > \textit =\long macro: #1->\ifmmode \nfss@text {\itshape #1}\else \hmode@bgroup \text@command {#1}\its hape \check@icl #1\check@icr \expandafter \egroup \fi . <recently read> \textit Runaway argument? {Hello ! Paragraph ended before \text@command was complete. <to be read again> \par l.5 \textit{Hello \par World.} Goodbye, cruel world! The \show\textit tells us that \textit is protected by a sneaky LaTeX trick. The following \show reveals the trick. Thus, since \textit is supposed to be a "long" macro, with one argument, I expect that it should be able to span paragraphs, and take one argument (rather than being a switch). But that is not the case, because internally, \textit contains \text@command, which has different behavior. This kind of situation is not unique to \textit.

  • Next odd-numbered physical page
    by Elayson Abreu on April 23, 2026 at 7:19 pm

    I need to create a page break command called \nextoddphysicalpage that moves the current point to the next odd-numbered page, considering the physical numbering of the document, not the logical numbering. My near-solution was based on the \checkoddpage command, but it takes into account the logical numbering, not the physical one: \documentclass{article} \usepackage[strict]{changepage} \def\checkifodd{\checkoddpage \ifoddpage Odd\else Even\fi} \addtocounter{page}{1} \begin{document} Logical page: \checkifodd. \end{document}

  • Interaction (?) of AtBeginDocument hooks
    by campa on April 23, 2026 at 6:55 pm

    In trying to boil down my problem to a MWE, I came to the following code: \begin{filecontents}[overwrite]{foo.cls} \ProvidesClass{foo} \LoadClass{article} \AtBeginDocument{\relax}% <-- comment this line out \RequirePackage{icomma} \AtBeginDocument{\show\mathcomma} \end{filecontents} \documentclass{foo} \begin{document} Hello world! \end{document} Running pdftex on this yields > \mathcomma=undefined. \__hook begindocument ->\relax \show \mathcomma \mathchardef \mathcomma \mat... l.9 \begin{document} while commenting out the first \AtBeginDocument one gets (./mwe.aux) > \mathcomma=\mathchar"613B. \__hook begindocument ...,="8000 \show \mathcomma \__hook_toplevel begindocu... l.9 \begin{document} Background (in case it matters) After loading icomma I'd like to calculate the math code of a \mathord comma, something along the lines of \RequirePackage{icomma}% this defines \mathcomma \AtBeginDocument \AtBeginDocument{\edef\ordcomma{\the\numexpr\mathcomma-4096*(\mathcomma/4096)\relax}} and this kept failing until I found out something seems to interact with the hook used before loading icomma.

  • package ebproof, left label usage
    by Jasper on April 23, 2026 at 10:46 am

    I am trying to typeset the forall introduction rule using ebproof, as suggested here: https://tex.stackexchange.com/a/762165/319072. I am reading the manual, but the left label key is not producing the expected result. I am getting this: and what I expect is this (credit Constructivism in Mathematics): \documentclass[letterpaper]{article} \usepackage{microtype} \usepackage{mathtools} \usepackage{unicode-math} \usepackage{ebproof} \begin{document} \[ \begin{prooftree} \hypo[left label=\forall I]{\overset{D_1}{A}} \infer1{\forall yA[x/y]} \end{prooftree} \] \end{document}

  • calculating tangent vectors with partial derivatives
    by Jasper on April 23, 2026 at 1:57 am

    I wanted to try calculating some tangent vectors for a picture, just for fun. This requires taking partial derivatives. It will be some time before I can automate partial derivatives algebraically for illustrations, even though it is a long term goal of mine. In the meantime, I want to see how people would suggest I approximate them. \documentclass[tikz,border=3.14mm]{standalone} \usepackage[3d]{luadraw}%https://github.com/pfradin/luadraw \begin{document} \begin{luadraw}{name=tangent} local g = graph3d:new{viewdir={30,60}, window={-4,4,-3,7}, size={12,12}, bbox=false} local f = function(u, v) return M( 3*math.cos(u)+math.cos(u)*math.sin(v), 3*math.sin(u)+math.sin(u)*math.sin(v), u+math.cos(v)) end -- local dfdu = ??? -- local dfdv = ??? local S = surface(f, 0, 2*math.pi, 0, 2*math.pi) g:Dfacet(S, {mode=mShadedOnly,color="blue"}) g:Show() \end{luadraw} \end{document}

  • Separate cases for real part and imaginary part [closed]
    by Tom Huntington on April 22, 2026 at 11:38 pm

    I am trying to recreate I want it working in github markdown, but github markdown doesn't support this trick Missing or unrecognized delimiter for \right \left. aaaa \right\} Edit Github requires you to use \lbrace and \rbrace \left. aaaa \right\rbrace

  • Help matching a Garamond math font
    by Jean Dubois on April 22, 2026 at 10:17 pm

    I am trying to match the style of a document (a French math exam, see the first image below). While I have identified the main text font as EB Garamond, I am struggling to reproduce the mathematical rendering (my current attempt is the second image). I am interested in knowing the name of the math font used in the document, as I do not think Garamond-Math is used (the symbols are different). I have also noticed that the original uses ligatures for internal "s" characters in italic (for example, "question" on the second line or "descente" on the third one), which I haven't been able to replicate. The reference (original): My current attempt (using EB Garamond and Garamond-Math): My code (I downloaded EB Garamond and Garamond-Math in the font folder), intended to work with XeLaTeX. \documentclass{article} \usepackage[fontsize=13pt]{scrextend} \usepackage[a4paper, margin=3.5cm]{geometry} \usepackage[french]{babel} \usepackage{fontspec} \setmainfont{EBGaramond}[ Path=./font/, Extension=.otf, UprightFont=*12-Regular, ItalicFont=*12-Italic, RawFeature={ +cv06, % narrow guillemets +calt, % Contextual alternates +clig, % Final s +liga, % f+letter, and Q, j in italic +dlig, % T+h +lnum % Numbers }, ItalicFeatures={ RawFeature={ +hlig, % st, ct, sp, sk +lnum % Numbers } } ] \usepackage[math-style=ISO, bold-style=ISO]{unicode-math} \setmathfont{Garamond-Math.otf}[Path=./font/,StylisticSet={ 1, % \mathbb 2, % \partial 9 % \tilde }] \begin{document} \frenchspacing \noindent\textit{Cette partie porte sur les fonctions convexes dont les gradients sont lipschitziens, établit le théorème de Baillon-Haddad à la question 21), lequel permet enfin d’étudier la convergence de la descente de gradient en l’interprétant comme une itération de Krasnoselskii-Mann.} \medskip Soit $f: \mathbb R^{n} \longrightarrow \mathbb R$ une fonction de classe $\mathscr C^{1}$. On note $\nabla f : \mathbb R^{n} \longrightarrow \mathbb R^{n}$ la fonction gradient qui a $x \in \mathbb R^{n}$ associe le vecteur $$ \nabla f (x) = \begin{pmatrix} \frac{\partial f}{\partial x_{i}}(x) \end{pmatrix}_{1 \leqslant i \leqslant n}. $$ \end{document} The full document is available here. Thank you for your help!

  • Append command to all superscripts and subscripts
    by MarcRdC on April 22, 2026 at 12:33 am

    I am using LuaHBTeX (TeX Live 2026) and would like to automatically append a command (say \mycmd, for example a sequence of characters) to all mathematical superscripts and subscripts, without making ^ and _ active — and without using some custom commands to write the said superscripts and subscripts. Could some lua code achieve that? Unlike gsub, it should also apply when symbols ^ and _ are not directly used in the body of the document. For instance, in math mode, a_{b}, a_{b^{c}} and \mytest, where \mytest is defined as a^{b}, should be respectively replaced with a_{b\mycmd}, a_{b^{c\mycmd}\mycmd} and a^{b\mycmd}. \documentclass{article} \def\mycmd{!} \def\mytest{a^{b}} \begin{document} % \verb+\( a_{b} \quad a_{b^{c}} \quad \mytest \)+ should give \( a_{b!} \quad a_{b^{c!}!} \quad a^{b!} \). \verb+\verb!a_b a^b!+ should give \texttt{a\_b a\textasciicircum b}. % \end{document}

  • Aligning text within a table cell so that it is centered horizontally and vertically
    by NotMyRealName on April 21, 2026 at 11:20 pm

    I have been googling for a while and have seen quite a few posts on this, but none of them seem to work. I would like to horizontally and vertically align the below table so that the text appears in the center of the column and the center of the row. I tried this with [b]{|c|}, hoping that this would align the text to the bottom (I also attempted this with [c]{|c|} and got no change. The reason that I use the m/p/b parameters is because I also need the columns to be a set width, I even made sure to include the array package. I had hoped that the b parameter would align the text to the bottom, and the m would align it to the middle, but again, none of them change anything. \documentclass[]{subfiles} \usepackage{array} \begin{document} \begin{table} \begin{center} \begin{tabular}{|m{2.1cm}|m{1.9cm}|m{1.9cm}|b{1.9cm}|m{1.9cm}|p{1.9cm}|b{1.9cm}|} \hline & \multicolumn{2}{c|}{Initial volume ($V_i$)} & \multicolumn{2}{c|}{Final volume ($V_f$)} & \multicolumn{2}{c|}{$\Delta V=V_{object}$} \\[20pt] \hline & [ml] or [cm$^3$] & [m$^3$] & [ml] or [cm$^3$] & [m$^3$] & [ml] or [cm$^3$] & [m$^3$] \\[20pt] \hline Lab Partner 1 & & & & & & \\[20pt] \hline Lab Partner 2 & & & & & & \\[20pt] \hline Lab Partner 3 & & & & & & \\[20pt] \hline & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{l|}{$\Delta V_{average}=$} \\[20pt] \hline \end{tabular} \end{center} \end{table} \end{document} Here is the output of the above (you'll notice that the m/b/p parameters all give the exact same result). How can I adjust this code to force the text to be both horizontally and vertically center aligned while maintaining the column widths?

  • Aligning TikZ grids between tcolorbox overlays and page background
    by Christopher Madec on April 21, 2026 at 9:13 pm

    I am working on a layout where I draw a grid in two different contexts: Inside tcolorbox environments (using an overlay) In the page margin using \AddToShipoutPicture Here is a minimal example: \documentclass[11pt,a4paper,svgnames]{book} \RequirePackage[top=2cm, bottom=2cm, left=3.9cm, right=1cm]{geometry} \usepackage[most]{tcolorbox} \newcommand{\myoverlay}{ \begin{tcbclipinterior}%[remember picture,overlay] \draw[%shift=(current page.north west), step=0.524cm,white!70!gray,very thin] (interior.north west) grid (interior.south east); \end{tcbclipinterior} } \newtcolorbox{Box4}[1][ bicolor, colback=white!05,grow to left by=2.5cm,colbacklower=black, boxrule=0.5pt,overlay=\myoverlay]{#1} \newtcolorbox{Box4bis}[1][ bicolor,colback=white,colbacklower=black, grow to left by=0cm,grow to right by=0cm, boxrule=0pt, overlay=\myoverlay] {#1} \usepackage{lipsum} \usepackage[]{eso-pic} \begin{document} \AddToShipoutPicture{% \begin{tikzpicture} \draw[shift=(current page.north west),step=5.24mm, lightgray, very thin, opacity=0.5] ([xshift=0cm,yshift=0cm]current page.south west) grid ([xshift=3.7cm,yshift=0cm]current page.north west); \draw[black, very thick, opacity=0.3] ([xshift=3.7cm]current page.south west) -- ([xshift=3.7cm]current page.north west); \end{tikzpicture}% } \begin{Box4bis} \lipsum[1] \end{Box4bis} \begin{Box4} \lipsum[2] \end{Box4} \lipsum[3] \begin{Box4} \lipsum[4] \end{Box4} \begin{Box4bis} \lipsum[5] \end{Box4bis} \end{document} The code gives this: Goal I would like the grids drawn: inside the tcolorbox environments in the page margin (via shipout) to be perfectly aligned, so that the grid appears continuous across the whole page. What I have tried Using current page coordinates inside the tcolorbox overlay Adding remember picture, overlay and current page.north page and retrieve absolute positions (see tikz: How can I find the value of `current page.north west`?) Trying to manually shift grids to match visually (impossible) However, I could not find a reliable way to make both grids share the same reference system.

  • Drawing card rows by using JeuxCartes
    by ryuk on April 21, 2026 at 9:10 pm

    Good evening, I've drawn 52 cards using the "JeuxCartes" package. I'd like to arrange the cards in 4 rows (one row per suit), but I can't. Could someone please help me? I would also like to introduce a little bit of space horizontally and vertically between one card and another. Thank you very much. \documentclass{standalone} \usepackage{amsmath,amssymb} \usepackage{pgfplots} \usepackage{JeuxCartes} \usepackage{eurosym} \begin{document} \\ \AffCartesJeu[Hauteur=2,StyleJeu=v3]{AT § 2T § 3T § 4T § 5T § 6T § 7T § 8T § 9T § 10T § VT § DT § RT} \\ \\ \\ \AffCartesJeu[Hauteur=2,StyleJeu=v3]{AK § 2K § 3K § 4K § 5K § 6K § 7K § 8K § 9K § 10K § VK § DK § RK} \\ \\ \\ \AffCartesJeu[Hauteur=2,StyleJeu=v1]{AC § 2C § 3C § 4C § 5C § 6C § 7C § 8C § 9C § 10C § VC § DC § RC} \\ \\ \\ \AffCartesJeu[Hauteur=2,StyleJeu=v2]{AP § 2P § 3P § 4P § 5P § 6P § 7P § 8P § 9P § 10P § VP § DP § RP} \\ \\ \end{document}

  • Strange bracket matching problem in exam class with the use of `\half` command
    by S. Venkataraman on April 21, 2026 at 9:43 am

    I get a strange error message when I use \half command in exam class. Here is a MWE. \documentclass{exam} \begin{document} \begin{questions} \question \begin{parts} \part \(\left[\half\left(A+A^*\right)\right]^*=\half\) % \part \(\left[\frac{1}{2}\left(A+A^*\right)\right]^*=\frac{1}{2}\) \end{parts} \end{questions} \end{document} In the present state, it gives this error message: ! Missing \right. inserted. <inserted text> \right . l.6 \part \(\left[\half \left(A+A^*\right)\right]^*=\half\) I've inserted something that you may have forgotten. (See the <inserted text> above.) With luck, this will get me unwedged. But if you really didn't forget anything, try typing `2' now; then my insertion and my current dilemma will both disappear. However, if I remove the comment from the second line and comment out the first line, it compiles successfully. My lualatex information is: This is LuaHBTeX, Version 1.22.0 (TeX Live 2025) (format=lualatex 2025.6.12) 21 APR 2026 15:09 What could be the problem?

  • Number shows up in worldflag
    by Erwann on April 21, 2026 at 5:21 am

    autoWorldFlag applies a scale factor to \f@size; I guess the dimension is poorly specified for the number .88 to show up in the output for \Huge. How then should it be set? \documentclass{article} \usepackage{worldflags} \usepackage{xparse} \ExplSyntaxOn % helper dimension \dim_new:N \l__flag_length_dim \makeatletter \NewDocumentCommand{\autoWorldFlag}{m} { \dim_set:Nn \l_tmpa_dim { 0.9pt * \f@size } \worldflag[ length = \dim_use:N\l_tmpa_dim , width = 0pt ]{#1} } \makeatother \ExplSyntaxOff \begin{document} \normalsize Document bilingue \autoWorldFlag{FR} \bigskip \large Document bilingue \autoWorldFlag{FR} \bigskip \Huge Document bilingue \autoWorldFlag{FR} \end{document}

  • How to optimize page space and event display in LaTeX with the Chronos timeline package?
    by Vincent on April 21, 2026 at 3:39 am

    I'm using the Chronos package to create a timeline with many events close together (e.g., 1937-1938). The text overlaps and it wastes too much space. How can I: Make the timeline more compact (reduce vertical/horizontal gaps)? Prevent text overlap and control text wrapping? Adjust spacing for dense event periods? For the following: \documentclass{article} \usepackage[margin=0.5cm,showframe]{geometry} \usepackage{chronos} \usepackage{xcolor} \begin{document} \noindent \begin{chronos}[ dates={1931}:{1946}, step minor year=2, step major year=10, timeline height=5pt, timeline width=\textwidth, timeline years=above, timeline era margin=50pt, ] \foreach \n/\d/\pos/\y in { Event 1/1931-9-18/above/yshift=2em, Event 2/1934-10/below/yshift=-2em, Event 3/1936-12-12/above/yshift=2em, Event 4/1937-7-7/below/yshift=-2em, Event 5/1937-8/above/yshift=4em, Event 6/1937-9/below/yshift=-6em, Event 7/1937-9/above/yshift=6em, Event 8/1937-12-13/above/yshift=8em, Event 9/1938-3/below/yshift=-10em, Event 10/1938-6/above/yshift=12em, Event 11/1940-8/below/yshift=-2em, Event 12/1941-12/above/yshift=2em, Event 13/1945-4/below/yshift=-2em, Event 14/1945-9-2/above/yshift=2em } \chronosevent{ name=\n, date=\d, place \pos=true, \y }; \end{chronos} \end{document} Produces: In a format analogous to the one depicted below:

  • Plot a domain in 3D with TikZ for a triple integral
    by Sebastiano on April 20, 2026 at 9:59 pm

    I have to solve this triple integral ∭ x y|z|³/(1+ (x²+y²)⁴)  dx  dy dz, with a domain T={(x, y, z) ∈ ℝ³: x ≤ 0, y ≥ 0, z² ≤ x²+y² ≤ 1}. Plotting with DESMOS 3D I see this: Actually I am not able to visualise this domain in my mind. It should be a cylinder enclosed by a double-sloped cone, but I can’t quite get the x ≤ 0, y ≥ 0 parameters right. I’ve created something but I would like my drawing (or a new one) to be intuitive with TikZ3D so that I can correctly draw this integral. My MWE: \documentclass[12pt]{article} \usepackage{tikz} \usepackage{tikz-3dplot} \tdplotsetmaincoords{60}{130} \begin{document} \begin{tikzpicture}[tdplot_main_coords, scale=3] % assi \draw[->] (0,0,0) -- (1.3,0,0) node[right]{$x$}; \draw[->] (0,0,0) -- (0,1.3,0) node[left]{$y$}; \draw[->] (0,0,0) -- (0,0,1.3) node[above]{$z$}; \foreach \t in {0,1,...,359}{ \pgfmathsetmacro{\ct}{cos(\t)} \pgfmathsetmacro{\st}{sin(\t)} \draw[blue!60, opacity=0.75] (0,0,0) -- plot[domain=0:1, samples=40] ({\x*\ct},{\x*\st},{\x}); \draw[red!60, opacity=0.75] (0,0,0) -- plot[domain=0:1, samples=40] ({\x*\ct},{\x*\st},{-\x}); } \draw[thick] plot[domain=0:360, samples=200] ({cos(\x)},{sin(\x)},1); \draw[thick] plot[domain=0:360, samples=200] ({cos(\x)},{sin(\x)},-1); \end{tikzpicture} \end{document}

  • expl3 e vs x function variants
    by karlh on April 20, 2026 at 8:06 pm

    In the LaTeX3 kernel documentation (interface3), it used to state, "The e specifier is in many respects identical to x, but with a very different implementation. Functions which feature an e-type argument may be expandable. The drawback is that e is extremely slow (often more than 200 times slower) in older engines, more precisely in non-LuaTeX engines older than 2019." I say "used to" because the current version changed the wording somewhat: "The e specifier is in many respects identical to x, but uses [the] \expanded primitive. [The] parameter character (usually #) in the argument need not be doubled. Functions which feature an e-type argument may be expandable." My question: other than the argument being allowed to be expandable in the e-form, is there a reason to prefer e over x or vice-versa, or do they do essentially the same thing? In particular, some functions (e.g., \iow_now:Nn) had x-variants in TeXLIVE 2023 but have e-variants now (the implication being that e is preferred, I would guess?), and I am wondering whether it makes any difference in terms of backward or forward compatibility of code I might write in the future.