• siunitx: Remove trailing zeroes
    by Ibrahim Onaran on July 3, 2025 at 2:41 pm

    I know that there are similar or identical questions, however I want to express it by myself. I want to remove trailing zeroes whenever they are placed in trailing position of the decimal part of the number. Since the numbers are computed I do not know the number just before typing. Here are some examples I want to achieve. Let the unit be Voltage (V). 3.5002121 V -> Use three decimal places. Therefore it would be 3.500 V, hence it has two trailing zeros and "3.5 V" should be shown. 3.5002121 V -> Use four decimal places. Therefore it would be 3.5002 V, hence it has no trailing zeros and "3.5002 V" should be shown. 3500.2121 V -> Engineering mode. As 3 decimal places are used it would be 3.500 kV. As it has 2 trailing zeroes, "3.5 kV" should be shown. 0.0035002121 V -> Engineering mode. As 3 decimal places are used it would be 3.500 mV. As it has 2 trailing zeroes, "3.5 mV" should be shown. That would be read as whenever a trailing zero in the decimal part shows up, it would be removed. Is that possible with siunitx package? \documentclass{scrbook} \usepackage{siunitx} \usepackage{booktabs} \begin{document} This table demonstrates the \texttt{round-pad=false} option in \texttt{siunitx}. \begin{table}[ht] \centering \sisetup { table-format=1.3, table-comparator=true, table-align-comparator = false, % optional detect-all, % Detect all units complex-angle-unit = radians, % Use radians for angles scientific-notation = engineering, % try to use next engineering unit instead of '.' per-mode = symbol, per-symbol = /, number-color=red, round-mode=places, % Round to significant figures round-precision=3, % Round to 3 decimal places } \begin{tabular}{c S[round-pad=false] S c} \toprule {Original} & {round-pad=false} & {round-pad=true} & {Expected} \\ \midrule 5.20 & 5.20 & 5.20 & 5.2 \\ 5.2 & 5.2 & 5.2 & 5.2 \\ 0.2461223 & 0.2461223 & 0.2461223 & 246.122 \\ 0.22310012 & 0.22310012 & 0.22310012 & 223.1 (milli) \\ 3900 & 3900 & 3900 & 3.9 (Kilo) \\ \bottomrule \end{tabular} \end{table} \end{document}

  • Old PSTricks drawing not working as it previously did
    by Svend Tveskæg on July 2, 2025 at 7:52 pm

    Consider the following drawing: \DocumentMetadata{} \documentclass{article} \usepackage{pstricks-add} \def\laengdeD{216} \def\bredde{120} \def\sti[#1]{% \pscustom[#1]{% \psarc(\fpeval{\laengdeD-\bredde/4},\fpeval{\bredde/4}){\fpeval{\bredde/4}}{-90}{90} \psarc(\fpeval{\laengdeD-\bredde/4},\fpeval{\bredde/4*3}){\fpeval{\bredde/4}}{-90}{90} \psframe(\laengdeD,\bredde)% }% }% \begin{document} \begin{figure} \centering \psset{ unit = 0.05 } \begin{pspicture}(224,128) \psclip{ \sti[ linestyle = none ] } \psframe[ fillstyle = vlines, % Fyldstil til området, der ikke må vandes. hatchcolor = black, % Farve til området, der ikke må vandes. hatchsep = 1pt, linestyle = none ](\fpeval{\laengdeD-\bredde/4},0)(\laengdeD,\bredde) \endpsclip \sti[] \psdots(\fpeval{\laengdeD-\bredde/4},\fpeval{\bredde/4}) (\fpeval{\laengdeD-\bredde/4},\fpeval{\bredde/4*3}) \psset{ arrows = |<*->|*, linestyle = dotted, offset = 12pt, nrot = :U } \pcline(0,\bredde)(\laengdeD,\bredde) \ncput*{\qty{\laengdeD}{\m}} \pcline(\laengdeD,\bredde)(\laengdeD,0) \ncput*{\qty{\bredde}{\m}} \end{pspicture} \end{figure} \end{document} Question As far as I remember, when I first had this drawing made (probably with the help of Herbert Voß), the two semicircles were not filled; only the two corners and the middle part of left side were filled. How do I change the drawing to achieve this once more?

  • Explode a group of slices in pgf pie
    by Papagon on July 1, 2025 at 6:39 pm

    on this tikzpicture, there are two exploded slices, but I would like them to be exploded "together", as a group. How may I do that? \documentclass[tikz, border=5pt]{standalone} \usepackage{amsmath} \usepackage{tikz,pgf-pie} \begin{document} \begin{tikzpicture}[scale=0.36] \pie[color={gray,white,white,gray,white},explode={0.2,0.2,0,0,0},hide number]{10,25,15,15,35}; \end{tikzpicture} \end{document} Thank you!

  • How to plot curve given implicitly
    by Apollonius on July 1, 2025 at 3:21 pm

    How do I use pgfplots to plot something like this? as you can see, this is the locus of the curve $x^2y+xy^2-x^4-y^4=0$. Here is an example which did work, where my work-around was to use a parametrisation of the curve. However, ideally I'm looking for a more direct solution. \documentclass[tikz, border=1cm]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=none, ] \addplot[ domain=-1.20:1.20, samples=100, smooth, black, variable=t, ] ({t^2 - 1}, {t^3 - t}); \end{axis} \end{tikzpicture} \end{document}

  • How to *locally* expose lua code in a .sty file
    by Jasper on June 30, 2025 at 9:07 am

    I want to make latex commands which run lua code. In particular, I want to know how to properly expose this lua code locally to a .sty file, so I don't have to require it in every newcommand. My big underlying goal here is to learn how to properly use lua and latex together. Reference: https://tex.stackexchange.com/a/742410/319072 % test.tex % arara: lualatex \documentclass[border = 1cm]{standalone} \usepackage{test} \begin{document} \begin{tikzpicture} \appendpoint{-1}{0} \appendpoint{1}{0} \appendpoint{0}{-1} \appendpoint{0}{1} \rotatepoints{math.pi/4} \renderpoints \end{tikzpicture} \end{document} % test.sty \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesPackage{test} [ 2025/06/30 v0.01 LaTeX package for an inquiry on TeX.SE. ] \RequirePackage{tikz} \newcommand{\appendpoint}[2]{ \directlua{ local test = require("test") test.append_point(#1,#2) } } \newcommand{\renderpoints}{ \directlua{ local test = require("test") test.render_points() } } \newcommand{\rotatepoints}[1]{ \directlua{ local test = require("test") test.list_of_points = test.mult( test.list_of_points ,test.rotate(#1) ) } } -- test.lua local test = {} test.list_of_points = {} function test.append_point(x,y) table.insert(test.list_of_points,{x,y,1}) end function test.render_points() for i = 1, #test.list_of_points do tex.print( string.format( [[ \fill (%f,%f) circle[radius = 0.1]; ]] ,test.list_of_points[i][1] ,test.list_of_points[i][2] ) ) end end function test.mult(A,B) local rows_A = #A local columns_A = #A[1] local rows_B = #B local columns_B = #B[1] assert( columns_A == rows_B ,string.format( [[ Wrong size matrices for multiplication. Size A: %f,%f Size B: %f,%f ]] ,rows_A,columns_A ,rows_B,columns_B ) ) local product = {} for row = 1, rows_A, 1 do product[row] = {} for column = 1, columns_B, 1 do product[row][column] = 0 for dot_product_step = 1, columns_A, 1 do product[row][column] = ( product[row][column] + A[row][dot_product_step] * B[dot_product_step][column] ) end end end return product end function test.rotate(angle) return { {math.cos(angle),math.sin(angle),0} ,{math.cos(angle+math.pi/2),math.sin(angle+math.pi/2),0} ,{0,0,1} } end return test

  • Is there a TECkit equivalent in LuaTeX?
    by yannis on June 29, 2025 at 6:33 pm

    XeTeX uses TECkit map files as a regular grammar to derive output character words from input character words. For example: U+0021 U+0060 <> U+00A1 ; produces a Spanish inverted exclamation mark from an exclamation mark followed by an ASCII grave accent. Is there, or can there be, something equivalent in LuaTeX?

  • Where and why does LuaLaTeX imports the lualibs libraries?
    by yannisl on June 29, 2025 at 8:28 am

    Consider the following MWE demonstrating that when compiling with LuaLaTeX there is no need to require("lualibs"). Where in the sources are these libraries loaded and why? \documentclass{article} \begin{document} testing \directlua{ for key,v in pairs(lualibs.module_info) do tex.print(-2,key .." = " .. v, " ") end } \end{document}

  • Expanding macros to string
    by LemeRus on June 28, 2025 at 1:37 pm

    I have macros for output first char of string. \makeatletter \def\firstchar#1{\expandafter\checkfirst#1\@nil} \def\checkfirst#1{% \ifx\UTFviii@two@octets#1% \expandafter\gettwooctets \else \expandafter\@car\expandafter#1% \fi } \def\gettwooctets#1#2#3\@nil{\UTFviii@two@octets#1#2} \makeatother It works if I pass a string directly like \firstchar{Иванович} If I pass macros with english string it also works correctly. But if I try \firstchar{\developerPatron} where \newcommand{\developerPatron}{Иванович} I see error ! LaTeX Error: Invalid UTF-8 byte sequence (�\nexttoken). \nexttoken is any token following \firstchar{…} call. I tried some variants with \expandafter. Below are variants of code and mathing errors. C: \expandafter\firstchar{\developerPatron} E: ! Missing \endcsname inserted. <to be read again> \protect E: ! LaTeX Error: Invalid UTF-8 byte sequence (�\endcsname\nexttoken). C: \expandafter\firstchar{\expandafter\developerPatron} E: ! Undefined control sequence. \firstchar #1->\expandafter \checkfirst #1\@nil E:! Argument of \@car has an extra }. <inserted text> \par E: Runaway argument? {}.\,\fi \developerSurName \color@endgroup ! Paragraph ended before \@car was complete. <to be read again> \par E: ! Extra }, or forgotten \endgroup. <recently read> } C: \expandafter\firstchar\expandafter\developerPatron E: ! Missing \endcsname inserted. <to be read again> \protect E: ! LaTeX Error: Invalid UTF-8 byte sequence (�\endcsname\nexttoken). How can I expand \developerPatron to \firstchar work correctly with cyrillic strings?

  • Use foreach loop variable in path coordinates
    by Franz on June 27, 2025 at 12:36 pm

    I have the following code: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary{fillbetween} \begin{document} \begin{tikzpicture} \begin{axis}[% axis x line=center, axis y line=center, xmax=2., xmin=-1., ymax=2., ymin=-1., ] \foreach \eps in { 1.0, 0.39810717, 0.15848932, 0.06309573, 0.01 }{ \addplot[ domain=\eps/\pgfkeysvalueof{/pgfplots/xmax}:\pgfkeysvalueof{/pgfplots/xmax}, samples=100, mark=none, name path=reg, ] {\eps/x}; % \path [name path=xaxis] % (\eps/\pgfkeysvalueof{/pgfplots/xmax}, 0.0) -- % (\pgfkeysvalueof{/pgfplots/xmax}, 0.0); % \addplot[ % gray, % opacity=0.5 % ] fill between [of=reg and xaxis]; } \end{axis} \end{tikzpicture} \end{document} Adding the commented lines I get an Undefined control sequence \eps error. Using \eps in the definition of the function and domain works. But apparently I cannot use it in the coordinates of a node. Could someone give me a brief explanation why this is the case? How can I make use of the value of \eps? EDIT: Using \closedcycle as suggested by samcarter_is_at_topanswers.xyz does not work for me as I need to use \eps also in other places. This is what I want the plot to look like (loop unrolled for two cases): \path [name path=yaxis] (0.0, 0.0) -- (0.0, \pgfkeysvalueof{/pgfplots/ymax}); \addplot[ domain=1/\pgfkeysvalueof{/pgfplots/xmax}:\pgfkeysvalueof{/pgfplots/xmax}, samples=100, mark=none, name path=reg, ] {1/x}; \path [name path=xaxis] (1/\pgfkeysvalueof{/pgfplots/xmax}, 0.0) -- (\pgfkeysvalueof{/pgfplots/xmax}, 0.0); \addplot[ gray, opacity=0.5 ] fill between [of=reg and xaxis]; \path [name path=toinf] (1/\pgfkeysvalueof{/pgfplots/xmax}, 0.0) -- (1/\pgfkeysvalueof{/pgfplots/xmax}, \pgfkeysvalueof{/pgfplots/ymax}); \addplot[ gray, opacity=0.5 ] fill between [of=yaxis and toinf]; \addplot[ domain=0.1/\pgfkeysvalueof{/pgfplots/xmax}:\pgfkeysvalueof{/pgfplots/xmax}, samples=100, mark=none, name path=reg, ] {0.1/x}; \path [name path=xaxis] (0.1/\pgfkeysvalueof{/pgfplots/xmax}, 0.0) -- (\pgfkeysvalueof{/pgfplots/xmax}, 0.0); \addplot[ gray, opacity=0.5 ] fill between [of=reg and xaxis]; \path [name path=toinf] (0.1/\pgfkeysvalueof{/pgfplots/xmax}, 0.0) -- (0.1/\pgfkeysvalueof{/pgfplots/xmax}, \pgfkeysvalueof{/pgfplots/ymax}); \addplot[ gray, opacity=0.5 ] fill between [of=yaxis and toinf]; Also using \closedcycle results in the axis lines been drawn multiple times as seen here:

  • Reference a TikZ coordinate from later in the picture
    by schtandard on June 26, 2025 at 8:19 am

    I want to clip a tikzpicture to a shape that is derived from a node in the tikzpicture (which should also be clipped). In order to do this, I need to know the node coordinates (for clipping) before the node is defined. How can I do this? Here's an MWE. The red box marks the desired clipping path. If I uncomment the \clip path at the start of the picture, I get the error No shape `testnode' is known., of course. \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} % \clip % (testnode.north west) % -- (testnode.south west) % -- (testnode.east) % -- (testnode.north east) % -- cycle; \draw [blue, very thick] (-1,0) sin (-.5,.5) cos (0,0) sin (.5,-.5) cos (1,0); \node (testnode) {This is a test}; \draw [red] (testnode.north west) -- (testnode.south west) -- (testnode.east) -- (testnode.north east) -- cycle; \end{tikzpicture} \end{document}

  • Save old command with \let which was redefined in an environment
    by one too many on June 25, 2025 at 5:50 pm

    I am writing some notes, where for brevity, I want to have a shorthand for arrows: \def\->{\ensuremath{\rightarrow}} \def\=>{\ensuremath{\Rightarrow}} which also improves the readability of code. Due to how (la)tex handles commands (no idea), \=> also overrides \= (similar for \-> and \-) The tabbing environment redefines the command \= as a tab placing marker. Thus \begin{tabbing} Some text \= with \tabs \\ in a \> new \> line \end{tabbing} is not working anymore. I can save the old command with \let\macron\=. However, this only saves the \= (macron) outside the tabbing environment. Question: How to use \let for a command redefined inside an environment? BTW: I solved the problem by using the tabular environment, which I actually prefer. I am asking out of curiosity.

  • Differences between \int_compare:nNnTF and \int_compare:nTF
    by chrispi_cookie on June 25, 2025 at 3:43 pm

    I'm writing a personal package where I compare some integer variables. Because \int_compare:nNnTF is around 5 times faster than \int_compare:nTF according to expl3 interfaces I tried the comparisons with the first one and noticed some differences in the evaluation of the integer expressions between both functions. What I've done: \documentclass{article} \begin{document} \ExplSyntaxOn \int_compare:nNnTF { 0 } = { 0test } { TRUE } { FALSE } % prints: testTURE \int_compare:nNnTF { 1 } = { 0test } { TRUE } { FALSE } % prints: testFALSE \int_compare:nTF { 0 = 0test } { TRUE } { FALSE } % error (LaTeX Error: Relation 't' not among =,<,>,==,!=,<=,>=) \int_compare:nTF { 1 = 0test } { TRUE } { FALSE } % error (LaTeX Error: Relation 't' not among =,<,>,==,!=,<=,>=) \ExplSyntaxOff \end{document} I expected the errors in the last two cases, but I thought all cases should result in errors. After some research the integer expressions in \int_compare:nNnTF are evaluated basically as \the\numexpr<integer-expression>\relax and \the\numexpr0test\relax gives indeed 0test. In contrast the definition for \int_compare:nTF is more complicated to support more relational symbols. According to the documentation, the integer expressions are evaluated in the same way for both functions (quotes from the documentation): \int_compare:nNnTF: "This function first evaluates each of the ⟨int expr⟩s as described for \int_eval:n". \int_compare:nTF: "This function evaluates the ⟨int expr⟩s as described for \int_eval:n". In fact, \int_eval:n { 0test } doesn't lead to an error either and prints 0test. Of course the t from test is interpreted as a relational operator because it is not an integer expression. But is it intended that \int_compare:nTF leads to errors while \int_compare:nNnTF evaluates something that is obviously not an integer expression, even though the evaluation should work identically?

  • Luatex version and format
    by LeO on June 23, 2025 at 1:45 pm

    With the usage of the PDF-Tagging we currently try to keep up to date with the versions of lualatex - especially with new and changed capabilities. If I look in the log file I see as first line something like This is LuaHBTeX, Version 1.22.0 (TeX Live 2025) (format=lualatex 2025.6.23) ... LaTeX2e <2025-06-01> patch level 1 L3 programming layer <2025-05-26> To my understanding the format is the important thing which is updated and defines the capability. Perhaps I'm wrong with the wording format - if so please correct me. When I use the following MWE \documentclass{article} \begin{document} \luatexbanner \end{document} I just get as printout the first part, namely This is LuaHBTeX, Version 1.22.0 (TeX Live 2025) Q: is there a way to include the format (or whatever is relevant for the PDF-Tagging) as well? Background: With the additional information I could easily spot with which version the PDF was compiled. UPDATE: The possible duplicate answer won't help since first of all the format is not printed on the command line with parameter --version. Next the commands there are for pdftex and won't apply to lualatex. Plus to my understanding the version of the format is not (directly) related to the TeX-version.

  • Interaction between \ifcat, \noexpand, and active characters
    by plante on June 20, 2025 at 7:24 pm

    I have come across the following oddity. Consider this example: \catcode`!=\active \let~=\empty \ifcat\noexpand~\noexpand! yes\else no\fi \let~=\relax \ifcat\noexpand~\noexpand! yes\else no\fi Why does the first \ifcat return yes while the second returns no? It seems that \empty can be any expandable token, and \relax can be any non-expandable token. I am unable to find any information in the TeXbook or TeX by Topic pertaining to this. But perhaps I am overlooking something simple. Many thanks!

  • Drawing two slices of bread framing a sausage or a slice of tomato
    by projetmbc on June 18, 2025 at 4:25 pm

    This is not a serious question. Here is a culinary variation of this post Drawing "two police officers" (squeeze theorem) metaphor with stylized uniforms for sequences. The squeeze theorem is also called the ‘sandwich theorem’, it would also be great fun to draw two slices of bread framing a sausage or a slice of tomato. PS: you can draw either wholemeal, semi-complete or white bread, or any other kind of bread.

  • Drawing "two police officers" (squeeze theorem) metaphor with stylized uniforms for sequences
    by Sebastiano on June 17, 2025 at 11:01 pm

    I'm working on a TikZ illustration to visually represent the squeeze theorem (also known as the sandwich theorem or two police officers theorem (in Italy "dei due carabinieri") in the context of sequences, with a playful metaphor: imagining the bounding sequences aₙ and bₙ as two "carabinieri" (police officers) guiding or squeezing the sequence cₙ. My idea is to visually depict the two sequences aₙ and bₙ as two human-like figures (the "carabinieri"), possibly wearing slightly modified uniforms that distinguish them from real police officers (for appropriateness), here a photo (the link is put looking the edit from this question): but still conveying the idea of symmetric bounding or convergence. I'd like to adapt their appearance to suggest authority or structure (maybe uniforms in different colors or styles). I would like to have, using tikzpeople package, a uniform that looks like that of a "carabiniere" by using the clothing of other people (e.g. uniform elements, hats, colors, etc.) adapting it to my case. My MWE: \documentclass[tikz]{standalone} \usepackage{tikz} \usepackage{tikzpeople} \begin{document} \begin{tikzpicture}[] \node[police,label=$a_n$, minimum size=1.5cm] (T) at (-1.5,0) {}; \node[criminal, label=$c_n$, minimum size=1.5cm] (S) at (0,0) {}; \node[police, label=$b_n$, mirrored,minimum size=1.5cm] (N) at (1.5,0) {}; \end{tikzpicture} \end{document}

  • Why doesn't `enlargelimits` appear to do anything in this graph?
    by Matthew Bourque on June 17, 2025 at 8:07 pm

    In the following MWE, I expected that the use of enlargelimits=true would enlarge the axis limits beyond the values which are computed from the function domain, and from the maximum and minimum function values computed for the graph. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat = newest} \begin{document} \begin{tikzpicture} \begin{axis}[ width = 5in, height = 3in, enlargelimits = true, axis x line = center, axis y line = center, xtick distance = 1, ytick distance = 0.5, grid = major, clip = false, domain = -6.28:6.28 ] \addplot[ <->, smooth, thick, blue, samples=101 ] {sin(deg(2*x+pi/4))}; \end{axis} \end{tikzpicture} \end{document} When I compile with pdfTeX (by way of latexmk, by way of VimTex), I get the following: The axes end exactly at the ends of my given domain, and at the max/min values computed for the function. I have also tried using enlargelimits = 0.2 with the same result. Why is that? How can I get the axes to enlarge a little bit in this plot?

  • What is the way to use vector arrow notation inline without interfering with descenders?
    by Jasper on June 14, 2025 at 8:04 pm

    What is the way to use vector arrow notation inline without interfering with descenders, and without making the linespacing less aesthetically pleasing? I am using the package overarrows for extensible arrows, for reference. \documentclass{article} \usepackage{overarrows} \begin{document} This text precedes the definition---in display math---of a vector, \[\overrightarrow{0}=\begin{bmatrix}0\\0\end{bmatrix}.\] Now I would like to refer to that vector inline. However, t{g}his takes up too much vertical space. If there were descenders above, then \(\overrightarrow{0}\) would interfere with them. \end{document}

  • How to tag a tikzpicture with a bounding box?
    by Teepeemm on June 14, 2025 at 3:16 pm

    In a previous question, I learned how to add alt text to a TikZ image. This validates as UA-1 according to VeraPDF. On the other hand, PDF Accessibility Checker says this is not UA-1 because the TikZ figure doesn't have a bounding box. How do I provide the bounding box to this figure? (Among other issues, we can get the size of the bounding box, but can't know the location until the page is shipped out.) I've come tantalizingly close with the following: % !TEX program = LuaLaTeX \DocumentMetadata{tagging=on,lang=en,pdfversion=1.7,pdfstandard=ua-1} \title{My Title} \documentclass{article} \usepackage{graphicx, tikz} \ExplSyntaxOn \dim_new:N \g_tpmm_dx_dim \dim_new:N \g_tpmm_dy_dim \cs_new:Nn \tpmm_setupBBox: { \node(current~bounding~box.south~west){\savepos}; \pgfextractx{\g_tpmm_dx_dim}{\pgfpointdiff{\pgfpointanchor{current~bounding~box}{west }}{\pgfpointanchor{current~bounding~box}{east }}} \pgfextractx{\g_tpmm_dy_dim}{\pgfpointdiff{\pgfpointanchor{current~bounding~box}{south}}{\pgfpointanchor{current~bounding~box}{north}}} \dim_gset_eq:NN \g_tpmm_dx_dim \g_tpmm_dx_dim \dim_gset_eq:NN \g_tpmm_dy_dim \g_tpmm_dy_dim \hook_gput_next_code:nn { shipout/after } { \tpmm_addBBox:ennee {\tag_get:n{struct_num}} {\lastxpos} {\lastypos} {\g_tpmm_dx_dim} {\g_tpmm_dy_dim} } } \cs_new:Npn \tpmm_addBBox:ennee #1#2#3#4#5 { \dim_set:Nn \g_tpmm_dx_dim { #4 } \dim_set:Nn \g_tpmm_dy_dim { #5 } \dim_add:Nn \g_tpmm_dx_dim { #2 sp } \dim_add:Nn \g_tpmm_dy_dim { #3 sp } % see latex-lab-testphase-graphic.sty \tag_struct_gput:ene{#1}{attribute} { /O /Layout /BBox~ [ \dim_to_decimal:n { #2 sp } \c_space_tl \dim_to_decimal:n { #3 sp } \c_space_tl \dim_to_decimal:n { \g_tpmm_dx_dim } \c_space_tl \dim_to_decimal:n { \g_tpmm_dy_dim } ] } } \hook_gput_code:nnn{env/tikzpicture/end}{tikz}{\tpmm_setupBBox:} \ExplSyntaxOff \begin{document} \tagstructbegin{tag=Figure,alt=a circle}\tagmcbegin{}% \SuspendTagging{tikz}% \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture}% \par \ResumeTagging{tikz}% \tagmcend\tagstructend \tagstructbegin{tag=Figure,alt=a circle}\tagmcbegin{}% \SuspendTagging{tikz}% \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture}% \par \ResumeTagging{tikz}% \tagmcend\tagstructend \tagstructbegin{tag=Figure,alt=a circle}\tagmcbegin{}% \SuspendTagging{tikz}% \begin{tikzpicture} \draw (0,0) circle (1cm); \end{tikzpicture}% \par \ResumeTagging{tikz}% \tagmcend\tagstructend \end{document} Unfortunately, it appears that multiple figures interfere with each other: their bounding boxes use entries 0 and 1 of the last figure, and entries 2 and 3 accumulate. How can I determine the bounding box of a TikZ picture?

  • In \tt, why do \char92 and \char'134 output the backlash '\', while \char"5c outputs 'Πc'?
    by ezequiel-garzon on June 14, 2025 at 2:16 pm

    \tt \char`\\ \char92 \char'134 \char "5c \bye outputs \\\Πc Why does it change using hexadecimal notation? Thanks in advance.

  • Is there better method to declare tikz picture with proper baseline and fontsize?
    by Explorer on June 13, 2025 at 11:52 am

    I want to use tikz to custom construct the following "steel" symbols: With my poor tikz practice, I get the following MWE: \documentclass{article} \usepackage{tikz} \newcommand*\steelA{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw (0,-.85ex) -- (0,.85ex); }}% \newcommand*\steelB{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw (0,-.85ex) -- (0,.85ex) (-.3em,-.85ex) -- (.3em,-.85ex); }}% \newcommand*\steelC{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw[xshift=-.1em] (0,-.85ex) -- (0,.85ex); \draw[xshift=.1em] (0,-.85ex) -- (0,.85ex); \draw (-.3em,-.85ex) -- (.3em,-.85ex); }}% \newcommand*\steelD{\tikz[baseline=(char.south),yshift=.8ex]{% \draw[thick] node (char) {} ellipse[x radius=.25em,y radius=.45ex]; \draw[xshift=-.1em] (0,-.85ex) -- (0,.85ex); \draw[xshift=.1em] (0,-.85ex) -- (0,.85ex); \draw (-.3em,-.85ex) -- (.3em,-.85ex) (-.3em,.85ex) -- (.3em,.85ex); }}% \begin{document} A\steelA B A\steelB B A\steelC B A\steelD B { \Huge% A\steelA B A\steelB B A\steelC B A\steelD B }% \end{document} But there are some drawbacks: poor method to handle the absolute distance(with some hard-encoded parameters(eg. .85ex)) the handle of baseline is not eleagnt, and not perfectly align: I want the top of the symbol EXACTLY the same height as A and B; and the bottom of the symbol the same depth as A and B When I test the different fontsize, it seemed that the symbol's thickness is too thin, is that possible to automaticallly change the thickness? Or in other word, how to better turn a tikzpicture into a "text symbol"? Sorry for (a little) mix three requirements together, but sepreate it into three questions seemed a bit inefficient. Thanks in advance! Edited with the symbol's information: but I don't know anything about these symbols, so maybe this style does not really make sense It comes from a standard file "GB 50010-2010"(I'm sorry for I can't provide the link here) at Page.22. The steel is graded into FOUR levels:

  • How to align arrow tips on curved lines in tikz
    by VladM on June 12, 2025 at 6:14 am

    I need to place mid-arrows on curved lines. The basic style works fine, but Latex and Stealth styles are not aligned properly. Is it possible to align arrow tip placement/direction with a curve? I also used a tikz block from TikZ: How to draw an arrow in the middle of the line? Below is my Latex code \documentclass[12pt]{article} \usepackage[headings]{fullpage} \usepackage{tikz,tikz-cd} \usetikzlibrary{positioning} \usetikzlibrary{calc} \usetikzlibrary{decorations.pathreplacing} \usetikzlibrary{decorations.markings} \tikzset{ % style to apply some styles to each segment of a path on each segment/.style={ decorate, decoration={ show path construction, moveto code={}, lineto code={ \path [#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); }, curveto code={ \path [#1] (\tikzinputsegmentfirst) .. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) .. (\tikzinputsegmentlast); }, closepath code={ \path [#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); }, }, }, % style to add an arrow in the middle of a path mid arrow/.style={postaction={decorate,decoration={ markings, mark=at position .5 with {\arrow[#1]{>}} }}}, mid stealth arrow/.style={postaction={decorate,decoration={ markings, mark=at position .5 with {\arrow[#1]{Stealth[]}} }}}, mid latex arrow/.style={postaction={decorate,decoration={ markings, mark=at position .5 with {\arrow[#1]{Latex[]}} }}} } \begin{document} $$ \begin{tikzpicture}[scale=1,baseline=20,x=5pt,y=5pt] \coordinate (t2) at (-5,-5); \coordinate (t3) at (0,6); \coordinate (t4) at (-4.5,-1); \coordinate (t5) at (-2.2,3.5); \path [draw,thick,postaction={on each segment={mid arrow}}] (t4) to[out=130,in=170] (t5) (t4) to [out=10, in=-60] (t5) (t2) to [out=90, in=-100] (t4) (t5) to [out=60, in=-135] (t3); \end{tikzpicture} \qquad,\qquad \begin{tikzpicture}[scale=1,baseline=20,x=5pt,y=5pt] \coordinate (t2) at (-5,-5); \coordinate (t3) at (0,6); \coordinate (t4) at (-4.5,-1); \coordinate (t5) at (-2.2,3.5); \path [draw,thick,postaction={on each segment={mid stealth arrow}}] (t4) to[out=130,in=170] (t5) (t4) to [out=10, in=-60] (t5) (t2) to [out=90, in=-100] (t4) (t5) to [out=60, in=-135] (t3); \end{tikzpicture} \qquad,\qquad \begin{tikzpicture}[scale=1,baseline=20,x=5pt,y=5pt] \coordinate (t2) at (-5,-5); \coordinate (t3) at (0,6); \coordinate (t4) at (-4.5,-1); \coordinate (t5) at (-2.2,3.5); \path [draw,thick,postaction={on each segment={mid latex arrow}}] (t4) to[out=130,in=170] (t5) (t4) to [out=10, in=-60] (t5) (t2) to [out=90, in=-100] (t4) (t5) to [out=60, in=-135] (t3); \end{tikzpicture} $$ \end{document} This code gives the output below. As you see, tips in the second and third picture are not aligned properly.

  • LaTeX TI Calculator Screen
    by user400857 on June 12, 2025 at 2:40 am

    I am working on a math tutorial using the TI calculator and I am using the tiscreen package. I can get the basic screen to pop up, but the documentation for the package is lacking. Does anyone know how to get it to highlight the selections (like the EDIT at the top) like the calculator does? Here's my working example code: \documentclass{standalone} \usepackage{tikz} \usepackage{xcolor} \usepackage[color]{tiscreen} \begin{document} \tiscreen |NAMES MATH EDIT | |1:[A] | |2:[B] | |3:[C] | |4:[D] | |5:[E] | |6:[F] | |7:[G] | \end{document} This is the output:

  • New conflict of subcaption and amsmath?
    by Bubaya on June 11, 2025 at 1:10 pm

    Can it be that there's a problem between subcaption and amsmath packages? The following code: \documentclass{article} \usepackage{subcaption,amsmath} \begin{document} \begin{figure} \subcaptionbox{\label{X}}{} \caption{(\subref{X})} \end{figure} \end{document} complains Reference 'sub@X' on page 1 undefined. If I don't load amsmath, the error goes away. I cannot reproduce the error on Overleaf (TL 2024). My latex installation is This is pdfTeX, Version 3.141592653-2.6-1.40.28 (TeX Live 2025) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (./test.tex LaTeX2e <2025-06-01> L3 programming layer <2025-05-26>

  • How can I utilize LaTeX to create a partitioned matrix
    by BqBPdx on June 8, 2025 at 1:25 pm

    This is the final result that I want. The matrix on the left can be implemented using the array environment, with dashed lines created by \hdashline, and the annotations for the right column implemented using superscripts ^ and subscripts _. However, this method doesn't seem to work for the matrix on the right, because it involves placing annotations above the matrix. Therefore, I want to use the nicematrix package, but this package cannot draw dashed lines between matrix elements. I think the matrix on the right should still be implemented using the array environment, but I don't know exactly how to do it. So I want to know how to draw the matrix on the right. Below is the code I tried. \documentclass{article} \usepackage{tikz} \usepackage{amsmath} \usepackage{nicematrix} \usepackage{arydshln} \usetikzlibrary{fit,patterns,arrows.meta,decorations.pathmorphing} \begin{document} \begin{equation} \renewcommand{\arraystretch}{1} \boldsymbol{\mu} = \left( \begin{array}{c} \boldsymbol{\mu}_{1} \\ \hdashline \boldsymbol{\mu}_{2} \end{array} \right)_{n-r}^{r} \end{equation} \begin{equation} \boldsymbol{\Sigma} = \begin{pNiceArray}{c|c}[first-row,last-col] r & n-r & \\ \boldsymbol{\Sigma}_{11} & \boldsymbol{\Sigma}_{12} & r \\ \hdashline \boldsymbol{\Sigma}_{21} & \boldsymbol{\Sigma}_{22} & n - r \end{pNiceArray} \end{equation} \end{document} Here is the pdf compiled. It looks weird compared Fig 1.

  • How to generate a range of alphabetical labels in an 'enumerate' environment?
    by Grass on June 8, 2025 at 3:54 am

    I find David Carlisle's custom command \itemrange[value] to be a pretty nice concept. However, as soon as I add \usepackage{enumitem} and [label=(\alph*)], everything breaks to my dismay. Does anyone have a nice analogue of \itemrange[value] that works more generally?

  • How can I render a circle diagram in tikz-cd?
    by Emily on June 7, 2025 at 6:04 pm

    How can I render the diagram and similar circle diagrams in tikz-cd in a clean way? I'm able to render it with the code \begin{tikzcd}[row sep={5.0*\the\DL,between origins}, column sep={5.0*\the\DL,between origins}, background color=backgroundColor, ampersand replacement=\&] \bullet \arrow[d] \arrow[dr, to path={(\tikztostart.east) arc[start angle=85,end angle=5,radius=4.6*\the\DL]}] \& \\ \bullet \arrow[r] \& \bullet \end{tikzcd} where \DL is defined with \newlength{\DL} and \setlength{\DL}{0.9cm}. However, using \arrow[dr, to path={(\tikztostart.east) arc[start angle=85,end angle=5,radius=4.6*\the\DL]}] requires some trial and error to find the values 85, 5, and 4.6. Meanwhile, doing something like \begin{tikzcd}[row sep={5.0*\the\DL,between origins}, column sep={5.0*\the\DL,between origins}, background color=backgroundColor, ampersand replacement=\&] \& \bullet \& \\ \bullet \& \bullet \& \bullet \\ \& \bullet \& % Arrows \arrow[from=1-2,to=2-2] \arrow[from=2-2,to=3-2] \arrow[from=2-1,to=2-2] \arrow[from=2-2,to=2-3] % \arrow[from=1-2,to=2-3, to path={arc[start angle=90,end angle=0,radius=5.0*\the\DL]}] \arrow[from=2-3,to=3-2, to path={arc[start angle=0,end angle=-90,radius=5.0*\the\DL]}] \arrow[from=3-2,to=2-1, to path={arc[start angle=-90,end angle=-180,radius=5.0*\the\DL]}] \arrow[from=2-1,to=1-2, to path={arc[start angle=-180,end angle=-270,radius=5.0*\the\DL]}] \end{tikzcd} produces which is also unsatisfactory. Question. What is a clean way to produce such circle diagrams specifically in tikz-cd?

  • The catcode of return (^^M) in shipout hook is 9 (instead of 5)
    by hair-splitter on June 7, 2025 at 1:33 pm

    After the June update of TeX Live, the catcode of `return' (^^M) in the shipout hook changes from 5 to 9. Is this intentional behavior or a bug? If intentional, what is the purpose of this? Here is an MWE: \documentclass{article} \AddToHook{shipout/foreground}{\put(1cm,-1cm){ The catcode of `return' in shipout hook: \number\catcode`\^^M }} \begin{document} text \end{document} This question is related to the following problem: Using \pgfornament in shipout hook causes an error

  • Problem with array 2.6.i
    by Christophe Poulain on June 5, 2025 at 7:28 pm

    Bonjour this code \documentclass{article} \usepackage{verbatim} \usepackage{array} \usepackage{longtable} \usepackage{hhline} \makeatletter \newwrite\verbatim@out \def\ExoCANWrite#1{% \@bsphack \immediate\openout \verbatim@out "#1" % \let\do\@makeother\dospecials \catcode`\^^M\active \def\verbatim@processline{% \immediate\write\verbatim@out{\the\verbatim@line}}% \verbatim@start} \def\endExoCANWrite{\immediate\closeout\verbatim@out\@esphack}% \makeatother \def\ArrayStretch{2} \begin{document} \begin{ExoCANWrite}{TestA} Hello\par World A ! \end{ExoCANWrite} \begin{ExoCANWrite}{TestB} Hello\par World B ! \end{ExoCANWrite} \begin{ExoCANWrite}{TestC} Hello\par World C ! \end{ExoCANWrite} \renewcommand{\arraystretch}{\ArrayStretch}% \begin{longtable}{|c|m{0.4\linewidth}|>{\centering\arraybackslash}m{0.35\linewidth}|m{0.1\linewidth}|}% \hhline{~---}% \multicolumn{1}{c|}{}&Question&Réponse&Jury\\% \hline% \endhead% 1&\input{TestA}&&\\ \hline 2&\input{TestB}&&\\ \hline% 3&\input{TestC}&&\\ \hline% \end{longtable}% \renewcommand{\arraystretch}{1}% \end{document} give me this with array 2.6 i and this with array 2.6.g

  • Parametric curve function in ConTeXt, using Lua. Specifically, how to input the parametric equations
    by Jasper on June 4, 2025 at 5:49 pm

    Reference: create a ConTeXt command which takes optional key=value parameters, as well as mandatory parameters I am trying to make a function which takes a parametric curve and inputs it to a list of segments, which will then be drawn in a separate command. I'm getting bad argument #1 to 'cos' (number expected, got nil). How can I correctly input the parametric equations? % test.tex \ctxloadluafile{test} \starttext \startMPcode \AppendCurve[ u_start = 0, u_end = 1, u_samples = 20, fx = "math.cos(u)", fy = "math.sin(u)", fz = "0" ] \rendersegments \stopMPcode \stoptext -- test.lua segments = {} local settings_to_hash = utilities.parsers.settings_to_hash local function append_curve(hash -- u_start -- ,u_end -- ,u_samples -- ,fx,fy,fz ) local hash = settings_to_hash(hash) or {} local u_start = hash.u_start or 0 local u_end = hash.u_end or 2*math.pi local u_samples = hash.u_samples or 3 local fx = hash.fx or math.cos(u) local fy = hash.fy or math.sin(u) local fz = hash.fz or 1.5 * math.sin(2 * u) local u_step = (u_end - u_start) / (u_samples - 1) local function parametric_curve(u) return {fx(u),fy(u),fz(u),1} end for i = 0, u_samples - 2 do local u = u_start + i * u_step local color = (u - u_start) / (u_end - u_start) local A = parametric_curve(u) local B = parametric_curve(u + u_step) -- the tables for surfaces have 5 values table.insert(segments, {A, B}) end end observer = {{0,0,1,1}} local function render_segments() for _, seg in ipairs(segments) do local S3, E3 = seg[1], seg[2] local Sx, Sy = Sp[1][1], Sp[1][2] local Ex, Ey = Ep[1][1], Ep[1][2] tex.print(string.format( 'draw (%.4fcm,%.4fcm) -- (%.4fcm,%.4fcm);', Sx, Sy, Ex, Ey )) end segments = {} end interfaces.implement { name = "rendersegments", actions = render_segments, public = true, arguments = {}, } interfaces.implement { name = "AppendCurve", actions = append_curve, public = true, arguments = { "optional" }, }