• How can I draw "rounded stars" in TikZ?
    by user319109 on June 2, 2025 at 2:08 pm

    I'm trying to draw rounded stars in TikZ that look similar to what so many AI applications nowadays are using. They look like the following: I modified some LaTeX code from another question to draw a single star that looks like the following: However, as you can see, the inner and outer angles are pointed and not rounded. I assume you can use some kind of (Bezier?) curves to draw the rounded points, but my TikZ skills are not high enough to know how to do this and I can't come up with the proper keywords to figure out how I can tackle this. How might I be able to draw these rounded stars? My code: \documentclass[tikz,dvipsnames]{standalone} \usepackage{tikz} \newcommand{\tstar}[5]{% inner radius, outer radius, tips, rot angle, options \pgfmathsetmacro{\starangle}{360/#3} \draw[#5] (#4:#1) \foreach \x in {1,...,#3} { -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1) } -- cycle; } \begin{document} \begin{tikzpicture} \tstar{1.75}{4}{4}{45}{thick,draw=none,fill=Purple} \end{tikzpicture} \end{document}

  • Improve booktabs table by fixing minor issues
    by XavierO on May 31, 2025 at 9:42 pm

    I am using the LaTeX package booktabs to present some results obtained in the paper. The style looks great, except for two minor issues that I don't know how to fix. The main one is the horizontal line below $m=20$, which does not extend to the end of the table. The other one is more delicate, as I am not sure if it is possible to fix it without massively changing the layout of the header. Ideally, the word "Region" should be aligned with the horizontal lines cmidrules, i.e. vertically centred in its cell. I will leave here an image of the table and the mwe to generate it. Other style suggestions to improve the appearance are also welcome. Thank you in advance. PS: The table is generated using the Springer template svjourn3 together with the mathptmx package. I have decided not to include it in the mwe, as I expect it to make no difference. \documentclass[10pt,a4paper]{article} \usepackage{booktabs} \usepackage{pdflscape} \begin{document} \begin{landscape} \begin{table}[h] %\centering \begin{tabular}{@{}lccccccccccccccc@{}} \toprule & \multicolumn{3}{c}{$m = 3$} & \multicolumn{3}{c}{$m = 5$} & \multicolumn{3}{c}{$m = 10$} & \multicolumn{3}{c}{$m = 15$} & \multicolumn{3}{c}{$m = 20$} \\ \cmidrule(r){2-4} \cmidrule(r){5-7} \cmidrule(r){8-10} \cmidrule(r){11-13} \cmidrule(r){14-16} \multicolumn{1}{l}{Region} & $\ell_\alpha$ & $\ell_{\Xi} / m$ & $\ell_{\xi}/m$ & $\ell_\alpha$ & $\ell_{\Xi} / m$ & $\ell_{\xi}/m$ & $\ell_\alpha$ & $\ell_{\Xi} / m$ & $\ell_{\xi}/m$ & $\ell_\alpha$ & $\ell_{\Xi} / m$ & $\ell_{\xi}/m$ & $\ell_\alpha$ & $\ell_{\Xi} / m$ & $\ell_{\xi}/m$ \\ \midrule Australia & $3.48 \%$ & $6.1$ & $35.45$ & $5.26\%$ & $9.4$ & $57.00$ & $5.85\%$ & $11.0$ & $64.13$ & $5.07\%$ & $ 9.9$ & $56.29$ & $4.20\%$ & $8.5$ & $47.19$ \\ Canada & $3.19\%$ & $9.8$ & $38.33$ & $5.29\%$ & $15.1$ & $58.36$ & $5.87\%$ & $17.5$ & $65.71$ & $5.09\%$ & $15.8$ & $57.65$ & $4.23\%$ & $13.5$ & $48.41$ \\ Europe & $3.50\%$ & $194$ & $38.86$ & $5.30\%$ & $296$ & $59.25$ & $5.90\%$ & $335$ & $66.88$ & $5.15\%$ & $297$ & $59.14$ & $4.13\%$ & $251$ & $50.11$\\ Germany & $3.48\%$ & $23.5$ & $40.06$ & $5.28\%$ & $35.8$ & $61.22$ & $5.90\%$ & $40.4$ & $69.24$ & $5.15\%$ & $35.6$ & $61.33$ & $4.32\%$ & $30.1$ & $52.06$ \\ Switzerland & $3.48\%$ & $2.3$ & $38.55$ & $5.29\%$ & $3.5$ & $58.90$ & $5.90\%$ & $4.1$ & $66.66$ & $5.13\%$ & $3.7$ & $58.94$ & $4.27\%$ & $3.1$ & $49.79$ \\ United States & $3.50\%$ & $80.0$ & $37.74$ & $5.30\%$ & $123$ & $57.46$ & $5.88\%$ & $141$ & $64.66$ & $5.10\%$ & $127$ & $56.79$ & $4.25\%$ & $108$ & $47.75$ \\ \bottomrule \end{tabular} \caption{Numerical results.} \label{tab:results} \end{table} \end{landscape} \end{document}

  • How to get a half or demi star symbol in LaTeX?
    by Name on May 31, 2025 at 11:05 am

    Is there a way to get a "half star" (half of \ast) symbol like the one shown in the below image? I tried using Detexify, but it did not find anything. Also, I could not find this symbol in the document "The Comprehensive LaTeX Symbol List (by Scott Pakin)." Does anyone know how to create or find a half star in LaTeX?

  • Curved or circular wires with circuitikz
    by Sebastiano on May 31, 2025 at 10:49 am

    In a physics textbook for the fourth year of an Italian high school with a focus on science and mathematics, pag. 407 "Le risposte della fisica - Edizione nuovo Esame di Stato by Antonio Caforio and Aldo Ferilli vol. 4", I see two circuits S1 and S2 where the wires are curved or circular paths — a non-standard, yet visually appealing style (I have added an image for the question 13 below). I’d like to ask whether it’s possible to reproduce such diagrams using the current features of the circuitikz package — that is, circuits with curved or closed-loop wires while still using the standard electrical symbols. I’ve looked through the official documentation but couldn’t find a way to achieve this kind of representation. Here’s a link to the textbook for reference: https://www.mondadorieducation.it/catalogo/le-risposte-della-fisica-edizione-nuovo-esame-di-stato-0063708/ Many thanks in advance to anyone who can help — especially to the very knowledgeable users who frequently share great advice on circuitikz! My MWE: \documentclass[a4paper,12pt]{article} \usepackage{circuitikz} \begin{document} \begin{tikzpicture} \draw (6, 7) to[battery2] (4, 7); \draw (4, 7) -- (4, 5) -- (6, 5) -- (6, 7); \draw (9, 5) to[battery2] (9, 7); \draw (9, 7) |- (7, 7) -| (7, 5) -- (9, 5); \end{tikzpicture} \end{document}

  • Adjusting spacing on subscript of binomial coefficient
    by diracdeltafunk on May 29, 2025 at 12:51 pm

    I am writing a bunch of equations involving $q$-binomial coefficients, denoted $\binom{n}{k}_q$. On my machine (in display mode), this renders as I'd like to reduce the amount of spacing between the left paren and the subscript -- here's a quick photoshop bodge of what I'd like to achieve: I can acheive something like this by using \binom{n}{k}_{\!\!q}, but I would guess that this ugly hack is not best practice. What's the best way to acheive this?

  • Should \mathop{f}(x) be used instead of f(x)?
    by JMC on May 28, 2025 at 3:33 pm

    This question probably pertains to taste just as much as to LaTeX best practices. When typesetting a simple function application, should mathop be used to reduce the space between the function and the parentheses enclosing its argument, in cases where the function is itself a variable like f(x)? MWE: \documentclass{article} \usepackage{mathtools} \usepackage{unicode-math} \setmainfont{Tex Gyre Pagella} \setmathfont{Tex Gyre Pagella Math} \begin{document} $f(x)$ vs $\mathop{f}(x)$ \end{document} Compare: To me, the second clearly looks better and more "correct", but I feel like nobody seems to use mathop for this purpose even though, in this case, "f" is an operator. Is this something that should be done?

  • TikZ package coding
    by Chesso on May 27, 2025 at 5:30 pm

    I'm trying to use the TikZ package to construct the picture above. I have the following code, but I keep receiving error messages. \documentclass{article} \usepackage{float} \usepackage{tikz} \begin{document} \begin{figure}[H] \begin{tikzpicture}[shorten >= 1pt, node distance=2cm, on grid, auto] \node[state, initial] (U0) at (0, 0){$U_0$}; \node[state] (U1) at (3, 2) {$U_1$}; \node[state] (U2) at (3, -2) {$U_2$}; \node[state, accepting] (U3) at (6, 0) {$U_3$}; \path[->] (U0) edge [bend right] node {(a)} (U2) (U0) edge [bend left] node {(b)} (U1) (U1) edge [bend left] node {(a)} (U3) (U1) edge node {(b)} (U2) (U2) edge [loop below] node {(a, b)} () (U3) edge [loop right] node {(a, b)} (); \end{tikzpicture} \end{figure} \end{document}

  • linear transformation of letter in MetaPost
    by Jasper on May 27, 2025 at 10:40 am

    In TikZ, it is possible to perform linear transformations on letters using transform shape. I seek the ability to perform linear transformations on letters in MetaPost. % mwe.tex \ctxloadluafile{mwe.lua} \starttext \mymacro \stoptext -- mwe.lua require("linalg") segments = {} function get_lines() segments = {} xmin = -5 xmax = 5 xsamp = 11 xstep = (xmax-xmin)/(xsamp-1) ymin = -5 ymax = 5 ysamp = 11 ystep = (ymax-ymin)/(ysamp-1) for xpos = xmin, xmax, xstep do local segment = { {xpos,ymin,1} ,{xpos,ymax,1} } table.insert(segments,segment) segment = la.mult(segment,transformation) table.insert(segments,segment) end for ypos = ymin, ymax, ystep do local segment = { {xmin,ypos,1} ,{xmax,ypos,1} } table.insert(segments,segment) segment = la.mult(segment,transformation) table.insert(segments,segment) end end function main() max = 23 for frame = 0, max, 1 do transformation = { {1,-1/2*frame/max,0} ,{1*frame/max,1,0} ,{0,0,1} } get_lines() context.startMPpage() for pos = 1, #segments, 1 do context( string.format( [[ draw (%f cm,%f cm) -- (%f cm,%f cm); ]] ,segments[pos][1][1] ,segments[pos][1][2] ,segments[pos][2][1] ,segments[pos][2][2] ) ) end context("label(btex \\scale[factor=60]{$M$} etex, (0,0));") context( [[ clip currentpicture to (-5cm,-5cm) -- (5cm,-5cm) -- (5cm,5cm) -- (-5cm,5cm) -- cycle; ]] ) context.stopMPpage() end end interfaces.implement { name = "mymacro", public = true, arguments = { }, actions = main, } -- linalg.lua la = {} --[[ Matrix multiplication ]] function la.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, "Wrong size matrices for multiplication.") 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 return la

  • How to place NiceMatrix on multiple lines
    by Dumbo on May 26, 2025 at 11:33 pm

    I am new to using nicematrix and need to align equations of matrices. I thought that using the align environnement from amsmath would do the trick, but with this example \documentclass{standalone} \usepackage{nicematrix,tikz} \begin{document} \tikzset{every path/.append style = { draw, dashed, rounded corners } } \begin{align} \begin{pNiceMatrix}[margin=2pt] \Block[tikz={offset=1pt,blue}]{3-3}{} & & \\ & S & \\ & & \\ \end{pNiceMatrix}&= \begin{pNiceMatrix} \Block[tikz={offset=1pt,blue}]{3-1}{} & \Block[tikz={offset=1pt,blue}]{3-1}{}& \Block[tikz={offset=1pt,blue}]{3-1}{}\\ & U & \\ & & \\ \end{pNiceMatrix} \begin{pNiceMatrix} \Block[tikz={offset=1pt,blue}]{1-1}{} & & \\ & \Block[tikz={offset=1pt,blue}]{1-1}{}D & \\ & & \Block[tikz={offset=1pt,blue}]{1-1}{}\\ \end{pNiceMatrix} \begin{pNiceMatrix} \Block[tikz={offset=1pt,blue}]{1-3}{} & & \\ \Block[tikz={offset=1pt,blue}]{1-3}{}& U^T & \\ \Block[tikz={offset=1pt,blue}]{1-3}{}& & \\ \end{pNiceMatrix}\\ \begin{pNiceMatrix}[margin=2pt] \Block[tikz={offset=1pt,blue}]{3-3}{} & & \\ & \tilde{S} & \\ & & \\ \end{pNiceMatrix}&= \begin{pNiceMatrix} \Block[tikz={offset=1pt,blue}]{3-1}{} & \Block[tikz={offset=1pt,blue}]{3-1}{}& \Block[tikz={offset=1pt,blue}]{3-1}{}\\ & U & \\ & & \\ \end{pNiceMatrix} \begin{pNiceMatrix} \Block[tikz={offset=1pt,blue}]{1-1}{} & & \\ & \Block[tikz={offset=1pt,blue}]{1-1}{}D & \\ & & \Block[tikz={offset=1pt,blue}]{1-1}{}\\ \end{pNiceMatrix} \begin{pNiceMatrix} \Block[tikz={offset=1pt,blue}]{1-3}{} & & \\ \Block[tikz={offset=1pt,blue}]{1-3}{}& U^T & \\ \Block[tikz={offset=1pt,blue}]{1-3}{}& & \\ \end{pNiceMatrix}\\ \end{align} \end{document} The code does not compile, stating that it needs to be in math mode.

  • How can I accurately compute the cross product of two vectors whose coordinates are rational numbers?
    by TTTT2025 on May 26, 2025 at 12:39 am

    I use this code to calculate the cross product of two vectors whose coordinates are integers. \documentclass{article} \usepackage{pgf} \usepackage{amsmath, nicematrix} \usepackage{esvect} \usepackage[left=1.5cm, right=1.5cm, top=2cm, bottom=2cm]{geometry} \newcommand{\crossproduct}[6]{% % Inputs: a1 a2 a3 b1 b2 b3 \pgfmathsetmacro{\cx}{#2*#6 - #3*#5} % a2*b3 - a3*b2 \pgfmathsetmacro{\cy}{#3*#4 - #1*#6} % a3*b1 - a1*b3 \pgfmathsetmacro{\cz}{#1*#5 - #2*#4} % a1*b2 - a2*b1 \[ \vv{a} = \begin{bmatrix} #1 \\ #2 \\ #3 \end{bmatrix}, \quad \vv{b} = \begin{bmatrix} #4 \\ #5 \\ #6 \end{bmatrix} \] \[ \vv{a} \wedge\vv{b} = \begin{bmatrix} \cx \\ \cy \\ \cz \end{bmatrix} \] } \begin{document} Find the scalar product of two vectors: \[ \vec{u} = (1,\ 2,\ 3),\quad \vec{v} = (4,\ 5,\ 6) \] \crossproduct{1}{2}{3}{4}{5}{6} represent using a determinant \[ \vec{u} \wedge \vec{v} = \left| \begin{NiceMatrix} \vec{i} & \vec{j} & \vec{k} \\ 1 & 2 & 3 \\ 4 & 5 & 6 \end{NiceMatrix} \right| \] Expand \[ = \vec{i} \begin{vmatrix} 2 & 3 \\ 5 & 6 \end{vmatrix} - \vec{j} \begin{vmatrix} 1 & 3 \\ 4 & 6 \end{vmatrix} + \vec{k} \begin{vmatrix} 1 & 2 \\ 4 & 5 \end{vmatrix} \] \[ = \vec{i}(12 - 15) - \vec{j}(6 - 12) + \vec{k}(5 - 8) = -3\vec{i} + 6\vec{j} -3\vec{k} \] \[ \Rightarrow \vec{u} \wedge \vec{v} = (-3,\ 6,\ -3) \] \end{document} How can I find \crossproduct{1/2}{-2/3}{3/4}{-5/6}{6/7}{-7/8} and get the answer

  • Definition of "fonts.handlers.otf.features.normalize"
    by Math Is Fun on May 25, 2025 at 12:57 am

    Consider the following plain LuaTeX example: \input luaotfload.sty \directlua{ fonts.handlers.otf.addfeature { name = "test", type = "kern", data = { ["A"] = { ["V"] = -500 } } } } \font\lmroman=LatinModernRoman:+TEST \lmroman AV \bye Despite having supplied a feature in uppercase letters (i.e. +TEST), luaotfload still uses the corresponding feature but with lowercase letters (i.e. test). This behavior does not seem to be documented in the luaotfload manual. After looking through luaotfload's code, I believe it is due to line 452 of luaotfload-features.lua: features.normal = normalize (processed_features) (try adding inspect(processed_features) and inspect(features.normal)), but I cannot find the definition of normalize. Any help is much appreciated.

  • Is that possible to extend the dash style with tabularray?
    by Explorer on May 22, 2025 at 7:38 am

    Description: I want to custom the dash dot line style with tabularray package, something as below in tikz: However, in tabularray's interface, it only provides: For example, in section 1.8 in texdoc tabularray-2025-A: Is that possible to use syntax like \begin{tblr}{colspec = {c|c|[dashdot]c|c}}, that is to customly define a new dash line style dashdot? A workaround: It need tabularray version 2025-A, to use tikz: \documentclass{article} \usepackage{tabularray} \UseTblrLibrary{tikz} \begin{document} \begin{table}[ht] \centering \caption{\textbf{????}} \begin{tblrtikzabove} \draw[dash dot] (2-2.north east) -- (5-2.south east); \end{tblrtikzabove} \begin{tblr}{colspec = {c|cc|c}} \hline ?? & ?? & ?? & ??\\ \hline \SetCell[r=3]{c}??? & ?? & ?? & \SetCell[r=3]{c}???\\ \hline & ?? & ?? & \\ \hline & ?? & ?? & \\ \hline ?? & ?? & ?? & ??\\ \hline \end{tblr} \end{table} \end{document} Further attempts: The interface in the workaround is not so elegant, so I tried to dive deeper, and I found that, there is a commond \NewTblrDashStyle in 2025-A: Claim: The following is based on 2025-A, some macronames changed between 2024-A and 2025-A: In documantation sec 9.13:New dash styles, it used: \NewDocumentCommand \NewTblrDashStyle { m m } { \seq_set_split:Nnn \l_tmpa_seq { ~ } {#2} \tl_set:Ne \l__tblr_a_tl { \seq_item:Nn \l_tmpa_seq {1} } \tl_set:Ne \l__tblr_b_tl { \seq_item:Nn \l_tmpa_seq {2} } \tl_set:Ne \l__tblr_c_tl { \seq_item:Nn \l_tmpa_seq {3} } \tl_set:Ne \l__tblr_d_tl { \seq_item:Nn \l_tmpa_seq {4} } \tl_if_eq:NnT \l__tblr_a_tl { on } { \tl_if_eq:NnT \l__tblr_c_tl { off } { \__tblr_dash_style_make_boxes:nee {#1} { \dim_eval:n {\l__tblr_b_tl} } { \dim_eval:n {\l__tblr_d_tl} } } } } which only accepted two arguments, I want to extend it to four, to gobble \ljhNewTblrDashStyle{dotdash}{on ~ .5pt ~ off ~ 1pt ~ on ~ 2pt ~ off ~ 1pt}: Here below is my attempt: \documentclass{article} \usepackage{tabularray} \ExplSyntaxOn \NewDocumentCommand \ljhNewTblrDashStyle { m m } { \seq_set_split:Nnn \l_tmpa_seq { ~ } {#2} \tl_set:Ne \l__tblr_a_tl { \seq_item:Nn \l_tmpa_seq {1} } % \tl_set:Ne \l__tblr_b_tl { \seq_item:Nn \l_tmpa_seq {2} } % \tl_set:Ne \l__tblr_c_tl { \seq_item:Nn \l_tmpa_seq {3} } % \tl_set:Ne \l__tblr_d_tl { \seq_item:Nn \l_tmpa_seq {4} } % \tl_set:Ne \l__tblr_e_tl { \seq_item:Nn \l_tmpa_seq {5} } % \tl_set:Ne \l__tblr_f_tl { \seq_item:Nn \l_tmpa_seq {6} } % \tl_set:Ne \l__tblr_g_tl { \seq_item:Nn \l_tmpa_seq {7} } % \tl_set:Ne \l__tblr_h_tl { \seq_item:Nn \l_tmpa_seq {8} } % \tl_if_eq:NnT \l__tblr_a_tl { on } { \tl_if_eq:NnT \l__tblr_c_tl { off } { \tl_if_eq:NnT \l__tblr_e_tl { on } { \tl_if_eq:NnT \l__tblr_g_tl { off } { \__tblr_dash_style_make_boxes:neeee {#1} { \dim_eval:n {\l__tblr_b_tl} } { \dim_eval:n {\l__tblr_d_tl} } { \dim_eval:n {\l__tblr_f_tl} } { \dim_eval:n {\l__tblr_h_tl} } } } } } } \cs_new_protected:Npn \__tblr_dash_style_make_boxes:nnnnn #1 #2 #3 #4 #5 { \dim_set:Nn \l_tmpa_dim { #2 + #3 + #4 + #5 } \tl_set:Nn \l__tblr_h_tl { \hbox_to_wd:nn } \tl_put_right:Ne \l__tblr_h_tl { { \dim_use:N \l_tmpa_dim } } \tl_put_right:Nn \l__tblr_h_tl { { \hss \vbox:n { \hbox_to_wd:nn {#2} {} \hrule height \lTblrDefaultHruleWidthDim } \hss \vbox:n { \hbox_to_wd:nn {#3} {} } \hss \vbox:n { \hbox_to_wd:nn {#4} {} \hrule height \lTblrDefaultHruleWidthDim } \hss \vbox:n { \hbox_to_wd:nn {#5} {} } \hss } } \prop_gput:NnV \g__tblr_defined_hdash_styles_prop {#1} \l__tblr_h_tl \tl_set:Nn \l__tblr_v_tl { \vbox_to_ht:nn } \tl_put_right:Ne \l__tblr_v_tl { { \dim_use:N \l_tmpa_dim } } \tl_put_right:Nn \l__tblr_v_tl { { \vss \hbox:n { \vbox_to_ht:nn {#2} {} \vrule width \lTblrDefaultVruleWidthDim } \vss \hbox:n { \vbox_to_ht:nn {#3} {} } \vss \hbox:n { \vbox_to_ht:nn {#4} {} \vrule width \lTblrDefaultVruleWidthDim } \vss \hbox:n { \vbox_to_ht:nn {#5} {} } \vss } } \prop_gput:NnV \g__tblr_defined_vdash_styles_prop {#1} \l__tblr_v_tl } \cs_generate_variant:Nn \__tblr_dash_style_make_boxes:nnnnn { neeee } \ljhNewTblrDashStyle{dotdash}{on ~ .5pt ~ off ~ 1pt ~ on ~ 2pt ~ off ~ 1pt} \ExplSyntaxOff \begin{document} \begin{table}[ht] \centering \caption{\textbf{????}} \begin{tblr}{colspec = {c|c|[dotdash]c|c}} \hline \textbf{???} & \SetCell[c=2]{c}\textbf{???} && \textbf{??}\\ \hline ?? & ?? & ?? & ??\\ \hline \SetCell[r=3]{c}?? & ?? & ?? & \SetCell[r=3]{c}?? \\ \hline & ?? & ?? & \\ \hline & ?? & ?? & \\ \hline \end{tblr} \end{table} \end{document} But the glue is NOT dealt with correctly. Questions: How to tune the glue inside \g__tblr_defined_vdash_styles_prop in my last failed attempt, or is this feature should be requested to tabularray?

  • zref-clever and amsthm's numberwithin
    by Jim Hefferon on May 21, 2025 at 3:01 pm

    I am trying to migrate an existing class from from cleveref to zref-clever. I'm having trouble getting the Theorem, Lemma, etc. (I think this is what zref-clever documenation calls the "type name.") With this class file test.cls \ProcessOptions \relax \LoadClass[twoside]{book} \usepackage{amsthm} \newtheorem{theorem}{Theorem}[section] \newtheorem{lemma}[theorem]{Lemma} \usepackage{hyperref} \usepackage{zref-clever} \zcRefTypeSetup{theorem}{ Name-sg = Theorem , name-sg = Theorem , Name-pl = Theorems , name-pl = Theorems , } \zcRefTypeSetup{lemma}{ Name-sg = Lemma , name-sg = Lemma , Name-pl = Lemmas , name-pl = Lemmas , } % For the index \usepackage{makeidx} \makeindex I use this test.tex file. \documentclass{test} \usepackage{blindtext} \begin{document} \chapter{Chapter One} \blindtext\index{Chapter one} \begin{theorem}\label{th:ch-one} \blindtext \end{theorem} \section{First section} \Blindtext\index{Chapter one!section one} \begin{theorem}\label{th:ch-one-section-one} \blindtext \end{theorem} \blindtext \section{Second section} \Blindtext\index{Chapter one!section two} \begin{theorem}\label{th:ch-one-section-two} \blindtext \end{theorem} \begin{lemma}\label{le:ch-one-section-two} \blindtext \end{lemma} Expect lemma from section two: \zcref{le:ch-one-section-two} \blindtext \printindex % need to run: makeindex test.idx \end{document}% The call for the cross reference is at the bottom of this file. I run pdftex and the cross reference is right, and the number of the result is 1.2.2 as expected. (The Index entries and links are also right.) But the cross reference says Theorem instead of the expected Lemma. In test.cls I've moved things before or after hyperref, etc., but nothing I tried made a difference. What am I missing?

  • Aligning equations at non-relations
    by schtandard on May 19, 2025 at 1:56 pm

    I want to align several equation lines using amsmath's align(ed) environments. For alignment, I want to use something else than a relation, e.g. an operator or an opening parenthesis. The documentation tells me In the structures that do alignment (split, align and variants), relation symbols have an & before them but not after—unlike eqnarray. Putting the & after the relation symbol will interfere with the normal spacing; it has to go before. This seems to focus mostly on not putting the & after a relation symbol, only implicitly specifying that alignment should take place at this class of symbols. So my questions are: Can I safely align at (some) other types of symbols without messing up the spacing? If yes, which types of symbols are safe? If no, can I somehow fix the messed up spacing (short of resorting to manually specifying explicit lengths)? Here's an example where I break a long example equation over two lines, aligning them at the inner +. It looks fine to me, but I'm wondering if there could be problems in general. \documentclass{article} \usepackage{amsmath} \begin{document} \begin{equation} \begin{aligned}[b] x = \biggl( - 12 a \Bigl( \frac{c}{a + b + c + d} &+ \frac{d}{a + b - c - d} \Bigr) \\ - 21 b \Bigl( \frac{c}{a - b + c - d} &+ \frac{d}{a + b - c + d} \Bigr) \biggr) \cdot y \end{aligned} \end{equation} \end{document}

  • Multicols and tabular environments problems
    by omnisum on May 18, 2025 at 3:45 pm

    I am trying to put some tables in two columns using the multicols environment. Since multicols do not supports floating environments, I decided to use to center environment to make tabular work. So I wrote the following code: \documentclass[11pt,twoside,openright,b5paper,table]{book} %[draft] %classe, tipo documento=book, dimensione=12pt, twoside=fronte-retro \pagestyle{plain} \usepackage[dvipsnames,table]{xcolor} \usepackage{colortbl} \usepackage[T1]{fontenc} %codifica dei font \usepackage[utf8]{inputenc} %lettere accentate da tastiera \usepackage{indentfirst} %rientro nel primo paragrafo \usepackage{siunitx} %unità di misura SI \usepackage{textcomp} %per simboli \usepackage[b5paper]{geometry} % [showframe] %modificare margini pagina \usepackage{latexsym} %simboli matematica \usepackage{hyperref} %collegamenti ipertestuali \usepackage{multirow} %multi riga \usepackage{nameref} \usepackage[page,toc]{appendix} \usepackage{amsmath} \usepackage{amssymb} \usepackage{longtable} % for 'longtable' environment \usepackage{pdflscape} % for 'landscape' environment \usepackage{xltabular} %____________________________________________________________ % ---LANGUAGE OPTIONS--- %____________________________________________________________ \usepackage[german, french, polish, italian, english]{babel} %lingua del documento %____________________________________________________________ % BLIOGRAFIA CON NATBIB & MULTIBIB %____________________________________________________________ \usepackage[sort,numbers,authoryear]{natbib} %bibliografia con natbib, caricato per avere stili natbib su multibib \let\oldbibliography\thebibliography \renewcommand{\thebibliography}[1]{% \footnotesize \oldbibliography{#1}% \setlength{\itemsep}{5pt}}% \usepackage{doi} \usepackage{url} %____________________________________________________________ %_______________________CHIMICA_____________________________ % \usepackage[version=4]{mhchem} %per formule chimiche \newcommand\reaction[1]{\begin{equation}\ce{#1}\end{equation}} \newcommand\reactionnonumber[1]% {\begin{equation*}\ce{#1}\end{equation*}} %____________________________________________________________ % ---Formattazione titoli--- %____________________________________________________________ % \usepackage{titlesec} %impostazioni titoli capitolo %------------------Impostazioni titoli----------------------- \titleformat{\chapter}{\filright\normalfont\huge\bfseries}{\thechapter}{20pt}{} %____________________________________________________________ % ---Tabelle e immagini--- %____________________________________________________________ % \usepackage[pdftex]{graphicx} % [draft] %per inserire immagini esterne \usepackage[bf,font=scriptsize,aboveskip=5pt,ruled,singlelinecheck=true]{caption} %paccheto di modifica per le didascalie \usepackage{float} %comandi di controllo per le opzioni di posizionamento delle immagini \usepackage[italian]{varioref} %pacchetto per migliorie ai riferimenti nel testo \usepackage{sidecap} %pacchetto per caption laterali \usepackage{subfig} %gestione sottofigure -richiede caption- \usepackage{rotating} %rotare tabelle e immagini \usepackage{booktabs} \usepackage{makecell} \usepackage{rotating} \usepackage{graphics} \usepackage[shortlabels]{enumitem} \usepackage{cleveref} \usepackage{afterpage} \usepackage{pdfpages} \usepackage{multicol} \begin{document} \begin{multicols}{2} \begin{center} \tiny \noindent \begin{tabular}{cccc} %Mn \toprule \multicolumn{4}{c}{Mn} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.0305} & -- & -- \\ z & 0.0976 & 0.09017 & -- \\ Gen. & 0.923 & 0.09802 & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %Fe \toprule \multicolumn{4}{c}{Fe} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.000228} & -- & -- \\ z & 0.0033 & 0.3163 & -- \\ Gen. & 0.875 & 0.8032 & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %Cu \toprule \multicolumn{4}{c}{Cu} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & 0.176 & 0.1588 & -- \\ z & 0.703 & 0.6695 & -- \\ Gen. & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.00716} & -- & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %Ga \toprule \multicolumn{4}{c}{Ga} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & 0.162 & 0.9453 & -- \\ z & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.0171} & -- & -- \\ Gen. & \cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} 0.232} & 0.2015 & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %Ge \toprule \multicolumn{4}{c}{Ge} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & 0.914 & 0.06998 & -- \\ z & \cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} 0.178} & 0.152 & -- \\ Gen. & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.0206} & -- & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %As \toprule \multicolumn{4}{c}{As} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.025599} & -- & -- \\ z & \cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} 0.12} & -- & -- \\ Gen. & 0.0332 & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.02819} & 0.7849 \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %Ag \toprule \multicolumn{4}{c}{Ag} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & \cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} 0.155} & \cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} 0.0496} & 0.5067 \\ z & \cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} 0.149} & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.04597} & -- \\ Gen. & \cellcolor[HTML]{C6EFCE}{\color[HTML]{006100} 0.0496} & \cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} --} & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %Cd \toprule \multicolumn{4}{c}{Cd} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & 0.125 & -- & -- \\ z & 0.391 & -- & -- \\ Gen. & 0.825 & -- & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %In \toprule \multicolumn{4}{c}{In} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & 0.557 & -- & -- \\ z & 0.594 & -- & -- \\ Gen. & 0.243 & -- & -- \\ \bottomrule \end{tabular} \vspace{3mm} \begin{tabular}{cccc} %Sn \toprule \multicolumn{4}{c}{Sn} \\ \midrule & Model I & Model II & Model III \\ \cmidrule{2-4} \multirow{-2}{*}{\begin{tabular}[c]{@{}c@{}}Independent \\ variable\end{tabular}} & p-value & p-value & p-value \\ \midrule xy & 0.653262 & -- & -- \\ z & 0.548 & -- & -- \\ Gen. & 0.33 & -- & -- \\ \bottomrule \end{tabular} \end{center} \end{multicols} \end{document} which basically works. The problem is that the tables are not vertically aligned at the top. How can I fix this problem? I did some attempts but none of them worked.

  • What does `\mathalpha` mean in unicode-math?
    by Andrew Stacey on May 15, 2025 at 8:37 pm

    Looking through unicode-math-table.tex, the characters are defined via commands like: \UnicodeMathSymbol{"1D7BC}{\mbfitsanssigma}{\mathalpha}{mathematical sans-serif bold italic small sigma}% I'm trying to understand this, in particular the third argument. The possibilities for this argument are: \mathaccent \mathaccentoverlay \mathaccentwide \mathalpha \mathbin \mathbotaccent \mathbotaccentwide \mathclose \mathfence \mathop \mathopen \mathord \mathover \mathpunct \mathrel \mathunder Some of these I recognise, such as \mathord and \mathbin, and I know that these are used to determine the spacing between characters (amongst other things). But according to TeX by Topic, the options are just ord, op, bin, rel, open, close, punct, and inner. And the luatex manual also implies that these are the only categories (from Section 7.5.2 Pairwise Spacing which lists all the primitives that control the spacing between classes). So what do the rest represent and how are the interpreted with regard to spacing? I picked \mathalpha as an example, but also because it's the least comprehensible in the above list: I can imagine that the accents simply inherit their spacing from whatever the base character is, similarly with the over and under. But it feels like \mathalpha should just be \mathord. Why is it not?

  • Generate plural forms of labels referenced with fancyref
    by user26918948 on May 15, 2025 at 1:32 pm

    Can I somehow generate the plural forms if multiple labels are referenced with fancyref? \documentclass[12pt,a4paper]{ltxdoc} \usepackage{fancyref} \begin{document} \begin{equation} \label{eq:pythagoras} a^2 + b^2 = c^2 \end{equation} \begin{equation} \label{eq:trivial} a = a \end{equation} \fref{eq:trivial} \fref{eq:pythagoras} leads to \enquote{equation (2) equation (1)} \hspace{-1.4em}but I need \enquote{equations (2) and (1)} \end{document}

  • `.initial:n` leads to an error when after `.inherit:n`?
    by zpding on May 13, 2025 at 8:44 pm

    This code originally from Inheritance of keys in expl3: \documentclass{article} \begin{document} \ExplSyntaxOn \keys_define:nn { a } { A .tl_set:N = \l__A_tl } \keys_define:nn { } { b .inherit:n = a, } \keys_define:nn { b } { B .tl_set:N = \l__B_tl, B .default:n = {DEFAULT}, % --> works B .initial:n = {INITIAL}, % --> error } \keys_set:nn { b } { A = x } \ExplSyntaxOff \end{document} output log: ! LaTeX Error: The key 'b/B' is unknown and is being ignored. For immediate help type H <return>. ... l.15 } why does .initial:n lead to an error when after a .inherit:n ?

  • How to draw variations of tikz pictures without copy and pasting?
    by Kenya on May 13, 2025 at 5:47 am

    I want to create the following tikz images: For now, I've just copy and pasted variations of the code below: \begin{tikzpicture}[scale=0.5] \tikzstyle{vertex}=[circle,draw,minimum size=10pt,inner sep=0pt] \node[vertex] (S-8) at (1.34,-2.98) [minimum size=15pt, fill=white] {$*1$}; \node[vertex] (S-9) at (1.34,-1.34) [minimum size=15pt, fill=gray] {}; \node[vertex] (S-10) at (2.98,-1.34) [minimum size=15pt, fill=gray] {}; \node[vertex] (S-11) at (4.61,-1.34) [minimum size=15pt, fill=gray] {}; \node[vertex] (S-12) at (4.61,-2.98) [minimum size=15pt, fill=white] {$*1$}; \node[vertex] (S-13) at (4.61,-4.61) [minimum size=5pt, fill=white] {}; \node[vertex] (S-14) at (2.98,-4.61) [minimum size=5pt, fill=white, label={-90: \Large $0$}] {}; \node[vertex] (S-15) at (1.34,-4.61) [minimum size=5pt, fill=white] {}; \draw (S-8) -- (S-9);\draw (S-8) -- (S-15);\draw (S-9) -- (S-8);\draw (S-9) -- (S-10);\draw (S-10) -- (S-9);\draw (S-10) -- (S-11);\draw (S-11) -- (S-10);\draw (S-11) -- (S-12);\draw (S-12) -- (S-11);\draw (S-12) -- (S-13);\draw (S-13) -- (S-12);\draw (S-13) -- (S-14);\draw (S-14) -- (S-13);\draw (S-14) -- (S-15);\draw (S-15) -- (S-8);\draw (S-15) -- (S-14); \end{tikzpicture} It works, but there has to be a more elegant solution so I can make more of these pictures.

  • Knuthian environment and Xparse
    by yannisl on May 12, 2025 at 12:17 am

    Consider the following code which creates a delimited command that creates a "Knuthian environment". In days bygone the argument against this type of construction was it could consume to much memory. (Not really a concern now). How can I replace this code with xparse but keep the delimiters. I don't want to write \begin...\end. I am aware of the +b specifier. The command will load a latin->Greek transliterator. It is fine for very long texts to have have a LaTeX style environment, but in many cases is only a few words. Note the example just bold faces the text to avoid posting the longer code with the transliterator. \documentclass{article} \usepackage{xcolor} \usepackage{lipsum} \long\def\GR#1\GR {% \begingroup \bfseries #1 \endgroup } \begin{document} \GR \lipsum[1-2]\GR \GR Some words only\GR and more \GR \color{blue}some other words \GR \end{document}

  • Add new glyph into an existing math font
    by Stephen on May 11, 2025 at 2:39 am

    I want to create a new glyph (parallel and equal to) into the Cambria Math font. So I proceed as follows: Copy Cambria Math.ttf Open it via fontforge Create a glyph in slot U+2427 (I don't know where is the proper place to put this new glyph into) Change the font name and font family name into CambriaMath-New and Cambria Math New respectively Generate new font CambriaMath-New.otf to the desktop Install it via fontbook Create mwe to test the font: % Compiler: lualatex \documentclass{article} \usepackage{unicode-math} \setmathfont{Cambria Math New} \begin{document} $\alpha$ \end{document} However, unicode-math complains that The first font loaded by unicode-math must be an (unicode-math) OpenType Math font (with script=math). and then uses Latin Modern Math instead. What should I do so that I can use the new font successfully? Thanks. Update Due to copyright reason, I tested again with latinmodernmath.otf, but the same result happened. Update I created a separate font called demo and put the glyph into slot U+E006 since it's in Unicode private use srea. After installing the demo font in my system, I tested the following example: \documentclass{article} \usepackage{unicode-math} \setmathfont{Cambria Math} \newcommand{\peq}{\mathrel{\hbox{\fontspec{demo}\char"E006}}} \begin{document} $\ell_1\peq\ell_2$ \end{document} I'm sure this is not the best practice. Any suggestions are welcome.

  • Make a square frame of equal size around some distinct characters
    by Jack on May 10, 2025 at 4:30 pm

    In order to display cards (AKQJT98765432) in a frame I have macro Fbox. The frames should be quadratic and all of the same size, adapted to the fontsize. I encounter 2 problems: The ‘Q’ has a depth that makes its frame higher. I can think of 2 solutions, but neither works correct: Do a combination of raising the ‘Q’ a bit and diminishing its size a little Increase the frame of the others to the size of the ‘Q’ For the first it would be necessary to test if a ‘Q’ is to be processed (but also for other purposes I need to test on #1). This leads to another problem (expansion?) Both \Fbox{Q} and \Fbox{\myqueen} work as expected. But \Fbox{\MyQueen} doesn't. I appreciate any help to solve this \documentclass{article} \usepackage{xspace} \def\myqueen{Q} \def\DoSomething#1{#1} \NewDocumentCommand{\MyQueen}{s t!}{% \bgroup% \IfBooleanTF{#1}{% \IfBooleanTF{#2}{Q}{Queen}% }{% \IfBooleanTF{#2}{q}{queen}% }% \egroup% \xspace% }% MyQueen \def\Fbox#1{% \setlength{\fboxsep}{0.2ex}% set inner space \setlength{\fboxrule}{0.1ex}% set line width \fbox{% \makebox[\height]{% \rule{0mm}{0.75em}% set box height \if#1Q\DoSomething{Q}\else#1\fi }% makebox }% fbox }% Fbox \begin{document} \Huge \Fbox{A}\Fbox{Q}\Fbox{9}\\ \Fbox{\myqueen}\\ \Fbox{\MyQueen*!} \end{document}

  • Recommended practices when creating CTAN archives for packages for inclusion in multiple TeX distributions?
    by cfr on May 10, 2025 at 6:04 am

    How can I adapt the archives I upload to CTAN to avoid problems in MikTeX, while adhering to CTAN requirements and TeX Live recommendations? Judging by the issues tracker on GitHub, I am not the only author whose packages effectively require TeX Live or manual installation because the MikTeX packages are broken1. #15 (2018-01) #111 #231 #367 (2023-05) #368 #370 #372 #456 (2024-12) #477 (Just now.) In cases like mine, packages which used to work fine in MikTeX break following a change to the package archive provided to CTAN. For example, a change to docstrip and/or removal of a TDS archive. In others, the cause is less clear. These issues appear difficult to resolve, presumably due to lack of resources on the part of the MikTeX maintainer (i.e. time/energy). Once incorrect recipes are in place, it appears difficult to get them fixed. I've also been unable to find any documentation for the recipe file format. I tried, nonetheless, to provide at least a starting point for potentially correcting the issue for my packages (#469), but these efforts have so far proved a complete failure. TDS archives might help, but CTAN is reluctant to host these routinely and often deletes them when included in uploaded archives. Moreover, even in cases where a TDS is provided, it does not seem sufficient to correct an existing problem. Is there a list of what MikTeX wants package authors to provide, similar to the lists provided by TeX Live (here) and CTAN (here and here)? Or is there any other advice for package authors on ways to help prevent breakage and facilitate corrections? 1.I do realise this is a short list relative to the number of packages in MikTeX, but a high proportion of them are mine, so I obviously take a disproportionate interest in the matter.

  • How can I adhere to the best practices when handling math for TikZ with Lua?
    by Jasper on May 9, 2025 at 10:24 pm

    I use pgfmath for making 3D illustrations with TikZ, but want to convert it to Lua. I was informed that many people do not adhere to the most "bureaucratic" approach when incorporating Lua into Ti*kZ to handle the math. This question is exactly about that: I want to adhere to the proper practices for this. What I know: It is preferable to use a separate .lua file instead of writing everything inside \directlua. I am under the impression that it is preferable to use luatexbase instead of \directlua(require"...") and \directlua{myfunction(\parameterone,\parametertwo,...) My goal is to pass off some heavy math from pgfmath to Lua. This is an introductory question which I will probably elaborate on in future questions, because I am trying to incorporate Lua into some pretty elaborate commands that I've made. Here is an MWE I've built: .tex % arara: lualatex \documentclass[ tikz ,border = 1cm ]{standalone} \usepackage{package} \begin{document} \begin{tikzpicture} \getplaneTwo[ n1a = 1 ,n1b = -2 ,n1c = 3 ,n1d = 4 ]{a} \draw[spath/use=planea]; \end{tikzpicture} \end{document} .sty \usetikzlibrary{spath3} \newif\ifscaleAxes \pgfqkeys{/pline}{ .is family % normal equation of plane ,n1a/.store in = \pline@noa ,n1b/.store in = \pline@nob ,n1c/.store in = \pline@noc ,n1d/.store in = \pline@nod % 3D boundaries ,xmin/.store in = \pline@xmin ,xmax/.store in = \pline@xmax ,ymin/.store in = \pline@ymin ,ymax/.store in = \pline@ymax ,zmin/.store in = \pline@zmin ,zmax/.store in = \pline@zmax % size of the "cube" ,size/.store in = \pline@size ,scale axes/.is if = scaleAxes ,scale x/.store in = \plinescalex ,scale y/.store in = \plinescaley ,scale z/.store in = \plinescalez % ZYZ Euler angle rotation matrix ,alpha/.store in = \pline@alpha % Z ,beta/.store in = \pline@beta % Y ,gamma/.store in = \pline@gamma % Z ,n1a = 1 ,n1b = 1 ,n1c = 1 ,n1d = 0 ,xmin = -5 ,xmax = 5 ,ymin = -5 ,ymax = 5 ,zmin = -5 ,zmax = 5 ,size = 5 ,alpha = 0 ,beta = 0 ,gamma = 0 ,scale x = 1 ,scale y = 1 ,scale z = 1 } \directlua{require("pv-math.lua")} \directlua{require("pv-get_plane.lua")} \newcommand{\getplaneTwo}[2][]{ \pgfqkeys{/pline}{#1} \directlua{ get_plane( \pline@size ,{\pline@noa,\pline@nob,\pline@noc} ,\pline@nod ,\pline@xmax,\pline@xmin ,\pline@ymax,\pline@ymin ,\pline@zmax,\pline@zmin ,"#2" ) } } pv-math.lua function cross_product(u,v) local x = u[2]*v[3]-u[3]*v[2] local y = u[3]*v[1]-u[1]*v[3] local z = u[1]*v[2]-u[2]*v[1] local result = {x,y,z} return result end function dot_product(u,v) local result = u[1]*v[1] + u[2]*v[2] + u[3]*v[3] return result end function norm(u) local result = math.sqrt((u[1])^2 + (u[2])^2 + (u[3])^2) return result end function ZYZ_rotation_matrix(angles,vector) local c1 = math.cosd(angles[1]) local c2 = math.cosd(angles[2]) local c3 = math.cosd(angles[3]) local s1 = math.sind(angles[1]) local s2 = math.sind(angles[2]) local s3 = math.sind(angles[3]) local x = ( (c1*c2*c3-s1*s3)*vector[1] + (-c1*c2*s3-s1*c3)*vector[2] + c1*s2*vector[3] ) local y = ( (s1*c2*c3+c1*s3)*vector[1] + (-s1*c2*s3+c1*c3)*vector[2] + s1*s2*vector[3] ) local z = ( -s2*c3*vector[1] + s2*s3*vector[2] + c2*vector[3] ) local result = {x,y,z} return result end function sphere(longitude,latitude) local x = (math.cosd(latitude)*math.cosd(longitude)) local y = (math.cosd(latitude)*math.sind(longitude)) local z = math.sind(latitude) local result = {x,y,z} return result end function normalize_vector(u) local norm = norm(u) local x = u[1]/norm local y = u[2]/norm local z = u[3]/norm local result = {x,y,z} return result end function orthogonal_vector(u) local v if (u[1]~=0 and u[2]==0 and u[3]==0) then v = cross_product(u,{0,1,0}) else v = cross_product(u,{1,0,0}) end result = v return result end pv-get_plane.lua function plane(u,v) end local intersections = {} local sorted_intersections = {} function add_intersection(i) end function get_plane( size,normal,d_value ,xmax,xmin,ymax,ymin,zmax,zmin ,name ) function plane(u,v) local x = (d_value-normal[2]*u-normal[3]*v)/normal[1] local y = (d_value-normal[1]*u-normal[3]*v)/normal[2] local z = (d_value-normal[1]*u-normal[2]*v)/normal[3] local result = {x,y,z} return result end for index, value in ipairs(intersections) do intersections[index] = nil end function add_intersection(i) if ( i[1]>=xmin and i[1]<=xmax and i[2]>=ymin and i[2]<=ymax and i[3]>=zmin and i[3]<=zmax ) then table.insert(intersections,{i[1],i[2],i[3]}) end end for y = ymin, ymax, ymax-ymin do for z = zmin, zmax, zmax-zmin do local x = plane(y,z)[1] add_intersection({x,y,z}) end end for x = xmin, xmax, xmax-xmin do for z = zmin, zmax, zmax-zmin do local y = plane(x,z)[2] add_intersection({x,y,z}) end end for x = xmin, xmax, xmax-xmin do for y = ymin, ymax, ymax-ymin do local z = plane(x,y)[3] add_intersection({x,y,z}) end end local n = normalize_vector(normal) local u = orthogonal_vector(n) local u = normalize_vector(u) local v = cross_product(n,u) for index, value in ipairs(sorted_intersections) do sorted_intersections[index] = nil end local centroid = {0,0,0} local number_of_points = 0 for index, value in ipairs(intersections) do for index, value in ipairs(centroid) do centroid[index] = centroid[index] + value end number_of_points = number_of_points + 1 end local centroid = { centroid[1]/number_of_points ,centroid[2]/number_of_points ,centroid[3]/number_of_points } for index, value in ipairs(intersections) do local ax = dot_product( {value[1]-centroid[1] ,value[2]-centroid[2] ,value[3]-centroid[3]} ,{u[1],u[2],u[3]} ) local ay = dot_product( {value[1]-centroid[1] ,value[2]-centroid[2] ,value[3]-centroid[3]} ,{v[1],v[2],v[3]} ) local anglea = math.atan2(ay,ax) table.insert( sorted_intersections ,{anglea,value[1],value[2],value[3]} ) table.sort( sorted_intersections ,function(a, b) return a[1] < b[1] end ) local path_one = "" for index, value in ipairs(sorted_intersections) do path_one = string.format(path_one.." (%f,%f,%f) --",value[2],value[3],value[4]) end tex.print("\\path[spath/save = plane"..name.."]"..path_one.."cycle;") end end

  • Single $ sign fixes an error in NewDocumentCommand
    by Nolord on May 7, 2025 at 10:08 pm

    For some reason, this macro creates no error \documentclass{article} \usepackage{xparse} \usepackage{amsmath} \NewDocumentCommand{\ex}{e{!}m}{ \exists\IfValueTF{#1}{!#1$}{#2} } \begin{document} $\ex!{z > 0}$ No error $\ex{x > 0}$ No error \end{document} and outputs even though there's a single $ in its definition. That's actually the fix I found for the Missing $ inserted, but this looks obviously wrong. This is a (minimal working) concept for inserting a character between a command and it's argument (but a not a useful one). It is supposed to {...} if the argument is either {...} or !{...}, while keeping the !. What's the issue? and the fix?

  • FiraMono and numbers
    by Kurt on May 6, 2025 at 3:50 pm

    I am currently trying to use the FiraMono Font in my LaTeX project. However, the numbers are... not aligned and simply look bad or out of scale. Take this minimal example: \documentclass{article} \usepackage{FiraMono} \begin{document} \Huge\texttt{1234567890} \end{document} which produces: where you can clearly see that the scaling or alignment of these seems to be off. Are there any fixes? I want to stick to pdflatex, so using fontspec is not an option.

  • How to prevent \chapter*{…} from appearing twice in EPUB table of contents?
    by obskyr on May 6, 2025 at 11:37 am

    Using TeX4ebook, try compiling the following file (tex4ebook -f epub test.tex) \documentclass{book} \begin{document} \tableofcontents \chapter*{Introduction} \addcontentsline{toc}{chapter}{Introduction} Blah blah blah… \end{document} The resulting file will, in its meta table of contents, contain “Introduction” twice – though note that it only appears once (as it should) in \tableofcontents in the document: The resulting navMap in the NCX file reveals why – both \chapter* and \addcontentsline are adding entries to the navigation: <navMap> <navPoint id="navPoint-1" playOrder="1"> <navLabel><text><navmark type="likechapter"></navmark> Contents</text></navLabel> <content src="testli1.html#x2-1000" /> </navPoint> <navPoint id="navPoint-2" playOrder="2"> <navLabel><text><navmark type="likechapter"></navmark> Introduction</text></navLabel> <content src="testli2.html#x3-2000" /> </navPoint> <navPoint id="navPoint-3" playOrder="3"> <navLabel><text><navmark type="chapter"></navmark> Introduction</text></navLabel> <content src="testli2.html#Q1-3-3" /> </navPoint> </navMap> And the matching HTML: <h2 class='likechapterHead' id='introduction'><a id='x3-2000'></a>Introduction </h2> <p id='introduction1'><a id='Q1-3-3'></a></p> <p class='noindent'>Blah blah blah…</p> How does one make TeX4Ht’s (i.e. TeX4ebook’s) behavior match what LaTeX does, that is to say adding a navigation entry with \addcontentsline but not with \chapter*?

  • Table with tabularx and multicolumn, unable to get correct cell widths
    by mlidal on May 5, 2025 at 11:33 am

    I'm trying to create a table which spans the entire page and where each row can have either one, two or three cells (each cell should have equal width.) I tried to use tabuarx with column type X and multicolumn but the cell widths aren't correct and the text in the wide cells (spanning the entire table) are wrapped on the smallest cell width. Do anyone know what I may be doing wrong? Here is an example: \documentclass{article} \usepackage{tabularx} \begin{document} \begin{tabularx}{\textwidth}{|X|X|X|X|X|X|} \hline \multicolumn{3}{|X|}{ asdf: } & \multicolumn{3}{|X|}{adsfasdfsadf asdf asdf } \\ \hline \multicolumn{6}{|X|}{asdfsadfs} \\ \multicolumn{6}{|X|}{ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea taki } \\ \hline \multicolumn{2}{|X|}{Tasldkjh } & \multicolumn{2}{|X|}{asdfasdf } & \multicolumn{2}{|X|}{fsadf }\\ \hline \multicolumn{6}{|X|}{fdsaa } \\ \hline \multicolumn{6}{|X|}{dasaf adsfasda asdf ads as fd} \\ \multicolumn{6}{|X|}{ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. D } \\ \hline \multicolumn{6}{|X|}{ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut la} \end{tabularx} \end{document} Example of how this ends up in overleaf: Ideally, here the two cells should cover half the width each and the text in the cells covering the entire table should fill the whole cell.

  • Getting suit symbols with pdflatex and luatex
    by Jack on May 5, 2025 at 10:46 am

    I have these questions: Running pdflatex I get black Clubs/Spades and white Diamonds/Hearts. Though I can live with that in my application, I wonder if it is possible to get them at wish black or white. Note: As I use them in a package, I must avoid loading fonts, if that would influence other parts of the document Running lualatex I gave to enter the math-mode explicitly. Is it possible to do without having to type the “$$” chars, as in pdflatex? I can use a macro like \Cl to do the work. Running lualatex causes a long delay setting up the math stuff. I need only these 8 characters. Can I tell lualatex to set up only these (or a limited range containing these) characters \documentclass{article} \usepackage{iftex} \ifpdftex \DeclareUnicodeCharacter{2660}{$\spadesuit$} \DeclareUnicodeCharacter{2661}{$\heartsuit$} \DeclareUnicodeCharacter{2662}{$\diamondsuit$} \DeclareUnicodeCharacter{2663}{$\clubsuit$} \DeclareUnicodeCharacter{2664}{$\spadesuit$} \DeclareUnicodeCharacter{2665}{$\heartsuit$} \DeclareUnicodeCharacter{2666}{$\diamondsuit$} \DeclareUnicodeCharacter{2667}{$\clubsuit$} \else \usepackage{unicode-math} \fi \begin{document} \ifpdftex ♣♦♥♠ ♧♢♡♤ \else $♣♦♥♠ ♧♢♡♤$ \fi \end{document}

  • Adding comparators to siunitx
    by deder on May 5, 2025 at 9:40 am

    I'm trying to use \lessapprox (⪅) within the SI package. It is not a default comparator, but there is the package option input-comparators described in the manuals. But I don't know how to use it. I tried: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[ input-comparators = \lessapprox %this doesn't work ]{siunitx} \begin{document} \SI{\leq 70}{\nano\meter} %this works fine \SI{\lessapprox 70}{\nano\meter} %this is what I want \end{document} Am I getting something wrong?