• how is \newcommand{\alphabet}{ab...} then \mathcal{\alphabet} different from \mathcal{abc...}?
    by Steven Thomas Hatton on April 21, 2025 at 7:49 pm

    This isn't a question of 'how to fix it?' Just 'what's going on?' I figure this should give some insight into how this Rube Goldberg contraption works. \documentclass[letterpaper,12pt]{article} \usepackage{amsmath} \usepackage{stix2} % begin preferred mathcal \DeclareMathAlphabet{\CMmathcal}{OMS}{cmsy}{m}{n} \SetMathAlphabet{\CMmathcal}{bold}{OMS}{cmsy}{m}{n} \DeclareMathAlphabet{\calomathcal}{U}{BOONDOX-calo}{m}{n} \SetMathAlphabet{\calomathcal}{bold}{U}{BOONDOX-calo}{b}{n} \ExplSyntaxOn \RenewDocumentCommand{\mathcal}{m} { \tl_map_function:nN {#1} \hatton_mathcal:n } \cs_new_protected:Nn \hatton_mathcal:n { \str_if_eq:eeTF {#1} {\str_lowercase:n {#1}} { \calomathcal{#1} } % lowercase { \CMmathcal{#1} } % uppercase } \ExplSyntaxOff % end preferred mathcal % begin stix2 fix %STIX doesn't provide fraktur numerals so... \NewDocumentCommand{\euffrak}{m}{\text{\usefont{U}{euf}{b}{n}#1}} \AtBeginDocument{% \NewCommandCopy\stixmathfrak\mathfrak \RenewCommandCopy\mathfrak\sthmathfrak } \ExplSyntaxOn \NewDocumentCommand{\sthmathfrak}{m} { \stixmathfrak { \tl_map_inline:nn {#1} { \str_case:nnF {##1} { {0}{\euffrak{0}} {1}{\euffrak{1}} {2}{\euffrak{2}} {3}{\euffrak{3}} {4}{\euffrak{4}} {5}{\euffrak{5}} {6}{\euffrak{6}} {7}{\euffrak{7}} {8}{\euffrak{8}} {9}{\euffrak{9}} } {##1} } } } \ExplSyntaxOff % end stix2 fix \newcommand{\alphabet}{abcdefghijklmnopqrstuvwxyz} \newcommand{\Alphabet}{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \newcommand{\numerals}{0123456789} \begin{document} \begin{align*} &\text{Alphabet}&:& \Alphabet\\ &\text{alphabet}&:& \alphabet\\ &\text{numerals}&:& \numerals\\ \end{align*} \begin{align*} &\text{mathcal Alphabet}&:&\mathcal{\Alphabet}\\ &\text{mathcal ABC...Z}&:& \mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ &\text{mathcal alphabet}&:& \mathcal{\alphabet}\\ &\text{mathcal abc...z}&:& \mathcal{abcdefghijklmnopqrstuvwxyz}\\ &\text{mathcal numerals}&:& \mathcal{\numerals}\\ &\text{mathcal 012...9}&:& \mathcal{0123456789}\\ \end{align*} \begin{align*} &\text{mathfrak Alphabet}&:&\mathfrak{\Alphabet}\\ &\text{mathfrak ABC...Z}&:& \mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\\ &\text{mathfrak alphabet}&:& \mathfrak{\alphabet}\\ &\text{mathfrak abc...z}&:& \mathfrak{abcdefghijklmnopqrstuvwxyz}\\ &\text{mathfrak numerals}&:& \mathfrak{\numerals}\\ &\text{mathfrak 012...9}&:& \mathfrak{0123456789}\\ \end{align*} \end{document}

  • LateX interlinear boxes not aligned
    by monstermash on April 21, 2025 at 9:05 am

    i am doing a 3 lined interlinear for the Burmese Judson Bible. I used an answer from this site. How come my boxes are not aligned? \documentclass[burmese]{article} \usepackage[provide=*]{babel} \babelfont{rm}{Padauk} \fboxrule1pt \fboxsep5pt \parindent3pt \begin{document} \def\add#1|#2|#3;{\fbox{\vbox{\hbox{#1}\hbox{#2}\hbox{#3}}}} \def\addsection#1{\fbox{\vbox to 1.1cm{\vfill\hbox to 1cm{\hfill\Large\bfseries #1}\vfill}}} \addsection{1.1a} \add အစဦး.၌| htoo| the beginning.in; \add နှုတ်ကပတ်.တော်| | The Word; \add ရှိ.၏။| | exists;\\ \addsection{1.1b} \add နှုတ်ကပတ်.တော်.သည်| | The Word; \add ဘုရားသခင်.နှင့်အတူ| | God.with together; \add ရှိ.၏။| | exists;\\ \addsection{1.1c} \add နှုတ်ကပတ်.တော်.သည်လည်း| | The Word.also; \add ဘုရားသခင်| | God; \add ဖြစ်.တော်.မူ၏။| | was;\\ \addsection{1.2} \add ထို.နှုတ်ကပတ်.တော်.သည်| | That.Word; \add အစဦး.၌| | the beginning.in; \add ဘုရားသခင်.နှင့်အတူ| | God.with together; \add ရှိ.၏။| | exists;\\ \addsection{1.3a} \add နှုတ်ကပတ်.တော်.သည်| | The Word; \add ခပ်သိမ်း.သော.အရာ.တို့.ကို| | all things; \add ဖန်ဆင်း.တော်မူ.၏။| | creates;\\ \addsection{1.3b} \add ဖန်ဆင်း.တော်မူ.ခြင်း.နှင့်| | The act of creating.with; \add ကင်းလွတ်.လျက် | | being apart; \add ဖြစ်.သော| | that which is; \add အရာ.တစုံတခု| | a single thing; \add မျှမ.ရှိ။| | not.never exist;\\ \end{document}

  • HowTo frame two align* environments side-by-side
    by Steven Thomas Hatton on April 21, 2025 at 3:35 am

    This is what I have: \documentclass[a4paper,10pt]{article} \usepackage{amsmath} \usepackage{stix2}% must follow amsmath or arrows get flinky. \usepackage[g]{esvect} \begin{document} \begin{align*} \mathfrak{p}_1\wedge\Delta\mathfrak{p} =&\mathfrak{p}_1\wedge\mathfrak{p}_2 =\mathfrak{p}_1\wedge\left(\mathfrak{p}_2-\mathfrak{p}_1 \right)\\ \mathfrak{p}_2\wedge\Delta\mathfrak{p} =&\mathfrak{p}_1\wedge\mathfrak{p}_2 =\mathfrak{p}_2\wedge\left(\mathfrak{p}_2-\mathfrak{p}_1 \right)\\ % \tilde{\mathfrak{L}} =&\pmb{\mathcal{J}}\cdot\Delta\mathfrak{p} =\begin{bmatrix} -\Delta p^y &\Delta p^x \end{bmatrix}\\ 0=&L_x \mathscr{p}^x+L_y \mathscr{p}^y+L_t\\ =&\tilde{\mathfrak{L}}\cdot\vv{\mathscr{p}}+L_t\\ =&\Delta\mathfrak{p}\wedge\vv{\mathscr{p}}+L_t\\ =&\mathfrak{p}_2\wedge\vv{\mathscr{p}} -\mathfrak{p}_1\wedge\vv{\mathscr{p}}+L_t \end{align*} \begin{align*} L_t=&\mathfrak{p}_1\wedge\Delta\mathfrak{p} =\mathfrak{p}_1\wedge\mathfrak{p}_2 \,\backepsilon\,\vv{\mathscr{p}}\mapsto\mathfrak{p}_1\\ % \mathfrak{L}=&\left\lbrace-\Delta y:\Delta x :\mathfrak{p}_1\wedge\mathfrak{p}_2\right\rbrace =\left\lbrace L_x:L_y:L_t\right\rbrace\\ =&\left\lbrace p^y_1-p^y_2:p^x_2-p^x_1 :p^x_1 p^y_2 -p^x_2 p^y_1\right\rbrace\\ 0=&L_x\mathscr{p}^x+L_y\mathscr{p}^y+L_t\\ =&-\Delta p^y\mathscr{p}^x+\Delta p^x\mathscr{p}^y +p^x_1 p^y_2 -p^x_2 p^y_1\\ =&\mathfrak{p}_2\wedge\vv{\mathscr{p}} +\vv{\mathscr{p}}\wedge\mathfrak{p}_1 +\mathfrak{p}_1\wedge\mathfrak{p}_2\\ =&\Delta\mathfrak{p}_2\wedge\vv{\mathscr{p}} +\mathfrak{p}_1\wedge\mathfrak{p}_2\\ \end{align*} \end{document} This is what I want, and did with Mathematica:

  • Unable to stop matrices from expanding when using \arraystretch
    by Mark A on April 20, 2025 at 8:05 pm

    I'm attempting to make a table of logical quantum gates in latex and I previously had a problem with the matrices overlapping with \raisebox so i used \vcenter{\hbox{...}} yet whenever I increase spacing the space between the rows in each matrix expands. \[ \renewcommand{\arraystretch}{2.2} \begin{array}{|l@{\hskip 1.5cm}c@{\hskip 1.5cm}c|} \hline \textbf{Operator} & \textbf{Gate(s)} & \textbf{Matrix} \\ \hline \text{Pauli-X (X)} & \Qcircuit @C=1em @R=.7em { & \gate{X} & \qw } & \vcenter{\hbox{$\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$}} \\ \text{Pauli-Y (Y)} & \Qcircuit @C=1em @R=.7em { & \gate{Y} & \qw } & \vcenter{\hbox{$\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}$}} \\ \text{Pauli-Z (Z)} & \Qcircuit @C=1em @R=.7em { & \gate{Z} & \qw } & \vcenter{\hbox{$\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$}} \\ \text{Hadamard (H)} & \Qcircuit @C=1em @R=.7em { & \gate{H} & \qw } & \vcenter{\hbox{$\dfrac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$}} \\ \hline \end{array} \] For reference this is what it looks like at 3.2 spacing:

  • New verbatim environment with block code (tagged-pdf)
    by Pablo González L on April 20, 2025 at 4:58 pm

    The scontents package provides an internal verbatim environment verbatimsc used by the \typestored command which works in the same way as the verbatim environment and can be customized using the fancyhdr, listings and minted packages. Unfortunately none of these options provide (yet) support for tagged pdf. If I use this code: \DocumentMetadata{lang = en-US,pdfversion = 2.0,pdfstandard = ua-2,testphase =latest} \documentclass{article} \usepackage{unicode-math} \usepackage{scontents} \begin{document} % environment \begin{scontents}[print-env=true] First code \verb|\foo| \end{scontents} % \typestored \typestored[1]{contents} \end{document} I get the following error: Package tagpdf Info: luamml has been enabled and will create an MathML file. Runaway argument? ! File ended while scanning use of \__scontents_xverb:w. <inserted text> \par l.12 \typestored[1]{contents} My first attempt is to undefine verbatimsc and use \UseInstance{blockenv} to redefine it. Here's the MWE: \DocumentMetadata{lang = en-US,pdfversion = 2.0,pdfstandard = ua-2,testphase =latest} \documentclass{article} \usepackage{unicode-math} \usepackage{scontents} \ExplSyntaxOn \cs_undefine:N \verbatimsc \cs_undefine:N \endverbatimsc \DeclareInstance{blockenv}{verbatiminternal}{display} { env-name = verbatiminternal, tag-name = verbatim, tag-class = , tagging-recipe = standard, inner-level-counter = , level-increase = false, setup-code = , block-instance = displayblock , inner-instance = , para-flattened = true } \NewDocumentEnvironment {verbatimsc} { } { \UseInstance{blockenv}{verbatiminternal} }{ \endblockenv } \ExplSyntaxOff \begin{document} % environment \begin{scontents}[print-env=true] First code \verb|\foo| \end{scontents} % \typestored \typestored[1]{contents} \end{document} But it returns the following error: Package tagpdf Info: luamml has been enabled and will create an MathML file. Runaway argument? ! File ended while scanning use of \template code > blockenv/display. <inserted text> \par l.33 \typestored[1]{contents} I'm using the updated TL2025 and lualatex-dev, but I'm a bit lost here. I read in a related post Tagged PDF & verbatim with line breaks that it's good to provide direct support for this, so my idea is to document how to make \typestored work with tagged pdf or implement it with some conditionals.

  • Changing the word "theorem" and "lemma" in \begin into something else
    by LLL on April 20, 2025 at 3:22 pm

    I want to create something like Theorem 1, Theorem 2, Lemma 3, etc but instead of theorem and lemma, it is something else, maybe like Algorithm 1, Algorithm 2, etc. I tried changing the word theorem into algorithm, for example changing the following \documentclass{article} \usepackage{enumitem} \usepackage{amsthm} \usepackage{amssymb} \usepackage{amsmath} \newtheorem{theorem}{Theorem}[section] \newtheorem{corollary}{Corollary}[theorem] \newtheorem{lemma}[theorem]{Lemma} \theoremstyle{remark} \newtheorem*{remark}{Remark} \theoremstyle{definition} \newtheorem{definition}{Definition}[section] \begin{document} \begin{theorem} content... \end{theorem} \end{document} into \documentclass{article} \usepackage{enumitem} \usepackage{amsthm} \usepackage{amssymb} \usepackage{amsmath} \newtheorem{theorem}{Theorem}[section] \newtheorem{corollary}{Corollary}[theorem] \newtheorem{lemma}[theorem]{Lemma} \theoremstyle{remark} \newtheorem*{remark}{Remark} \theoremstyle{definition} \newtheorem{definition}{Definition}[section] \begin{document} \begin{algorithm} content... \end{algorithm} \end{document} will throw Environment algorithm undefined error (sorry I'm new at LaTeX, I don't know how it works, i was just copy pasting code). So how do I do it?

  • How to use tex.toks?
    by Alain Matthes on April 20, 2025 at 10:10 am

    How to get the same result with tex.toks[3] = "\\texbf{Texte en gras}" \documentclass{article} \begin{document} \directlua{ tex.toks[3] = "Texte en gras" } \textbf{\the\toks3} \end{document}

  • Load a single letter from a font
    by Luluio on April 20, 2025 at 8:36 am

    I recently noticed that in physics gluons are usually typeset with (what I believe is called) a single-story g. The default g that comes with STIX Two Math – the math font I am using – is the double-story g and I would like to keep it that way for any variables called "g" that are not representing a gluon. My idea was to store it in a command similar to how \ell creates a script version of the letter "l" for quick access. STIX Two Math has a single-story g when applying stylistic set ss02. How could I load this g and store it in a command? A minimal example to work with should be: \documentclass{scrartcl} \usepackage{fontspec} \usepackage{mathtools} \usepackage{unicode-math} \setmainfont{STIX Two Text} \setmathfont{STIX Two Math} \begin{document} \[g\] \end{document}

  • Restoring parskip in tables (more specifically tabularray)
    by Harry on April 20, 2025 at 5:57 am

    @markus-kuhn offered an excellent answer to restoring parskip spacing in minipages in this thread with: \usepackage{parskip} \setlength{\parskip}{\medskipamount} \newcommand{\@minipagerestore}{\setlength{\parskip}{\medskipamount}} Can the same be done for tables? The only solution that I can see is using \medskip\par, which is great, but not an automatic solution (which is what I am looking for). I'd also ideally like to keep using column type X or equivalent. MWE: \documentclass{article} \usepackage{tabularray} \begin{document} \begin{center} \begin{tblr}{ colspec={| X | X |}, hlines, row{1}={halign=c} } Current Output & Expected Output \\ Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text. More text text text text. More text text text text text text & Text Text Text Text \medskip\par Text Text Text Text Text Text Text Text Text Text Text Text. \medskip\par More text text text text. More text text text text text text \\ \end{tblr} \end{center} \end{document}

  • inkscape adds serifs
    by jetrca on April 19, 2025 at 9:05 pm

    When I convert latex generated pdfs to svg using inkscape, the svg has serifs, where the original pdf does not. Take thic code, for example: \documentclass{article} \usepackage{graphicx} \newcommand{\breite}{50cm} \usepackage[margin=50mm,paperheight=\breite,paperwidth=\breite]{geometry} \parindent0mm \begin{document} \resizebox{30cm}{!}{\sf\textbf{K}} \end{document} The pdf displays an SF K But inkscape test.pdf -o test.svg delivers a K with serifs. How can I preserve the \sf property during file format convertions with inkscape? Thank you in advance!

  • Understanding \pdfstartlink options
    by Slurp on April 19, 2025 at 6:25 pm

    I am going through the pdfTeX manual and after unravelling the usage of \pdfstartlink, I see that the following is a possible usage: \pdfstartlink goto named <general text> <general text> (Specifically, \pdfstartlink goto <page spec> <general text> is valid usage, and <page spec> may refer to either page <number or named <general text>) Now, I see no reference to this usage in the manual itself. The only thing the manual says about specifying <page spec> after \pdfstartlink is "The <page spec> alternative specifies a page number for the destination. In this case, the zoom factor is given by <general text>" I'm guessing that <page spec>'s <general text> is a name that is a reference to a page (the name I assume would be in the Pages subdictionary of the document catalog's Names entry). But the pdfTeX manual doesn't seem to mention any references for naming pages. I'd greatly appreciate it if someone could shed some light on what exactly this option does, and how to use it. Thank you!

  • tikz gradient not working on path
    by Simon on April 19, 2025 at 1:37 pm

    I am trying to fill a path using gradient, but it is not working. the Entire path is solid color. I tried \path and \shade but the result is the same. How to fill the path with gradient? Adding transparency to the corners would be a plus in a seperate example. \documentclass[letterpaper]{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \pgfdeclarehorizontalshading{gradient}{100bp}{color(0bp)=(white); color(25bp)=(red); color(75bp)=(red); color(100bp)=(white)} \shade[shading=gradient, shading angle=0] (0,0) .. controls (0,2mm) and ({0.25*80mm},2mm) .. ({0.25*80mm},2mm) -- ({0.75*80mm},2mm) .. controls ({0.75*80mm},2mm) and (80mm,2mm) .. (80mm,0) .. controls (80mm,-2mm) and ({0.75*80mm},-2mm) .. ({0.75*80mm},-2mm) -- ({0.25*80mm},-2mm) .. controls ({0.25*80mm},-2mm) and (0,-2mm) .. (0,0) -- cycle; \end{tikzpicture} \end{document}

  • I am getting the error message `! error: (linebreak): invalid list tail, probably missing glue'
    by S. Venkataraman on April 19, 2025 at 11:36 am

    I am getting the error message `! error: (linebreak): invalid list tail, probably missing glue' in lualatex. This is the MWE: \documentclass{exam} \usepackage{amsmath} \usepackage{unicode-math} \usepackage[english, bidi=basic]{babel} \babelprovide[import=hi, onchar=fonts ids]{hindi} \babelfont{rm} [Ligatures={Common, TeX},Renderer=HarfBuzz]{Noto Serif} \babelfont[hindi]{rm} [Scale=MatchUppercase,Renderer=HarfBuzz]{Noto Serif Devanagari} \setmathfont{XITSMath-Regular} \setsansfont{Noto Sans} % \newfontfamily{\englishfont}{XITS}[Scale=1.1] \begin{document} \begin{questions} \question[15] \begin{parts} \part[3] मान लीजिए \(A\) एक \(m\times n\), \(B\) एक \(n\times k\) और \(C\) एक \(m\times k\) आव्यूह है। निन्मलिखित में से कौन-से संक्रियाएँ साध्य हैं? \begin{subparts} \subpart \(AB+C\) \subpart \(A^tC+B\) \end{subparts} जो संक्रियाएँ साध्य है उससे प्राप्त आव्यूह की कोटि क्या होगी? \end{parts} \end{questions} \end{document} I found a similar question here, but this has no answers because the error couldn't be reproduced. I hope my MWE fares better. Here is the log file This is LuaHBTeX, Version 1.18.0 (TeX Live 2024) restricted system commands enabled. (./noto-font-problem.tex LaTeX2e <2024-11-01> patch level 1 L3 programming layer <2024-12-25> (d:/texlive/2024/texmf-dist/tex/latex/exam/exam.cls Document Class: exam 2023/07/09 Version 2.704 by Philip Hirschhorn (d:/texlive/2024/texmf-dist/tex/latex/base/ifthen.sty) (d:/texlive/2024/texmf-dist/tex/latex/base/article.cls Document Class: article 2024/06/29 v1.4n Standard LaTeX document class (d:/texlive/2024/texmf-dist/tex/latex/base/size10.clo))) (d:/texlive/2024/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (d:/texlive/2024/texmf-dist/tex/latex/amsmath/amstext.sty (d:/texlive/2024/texmf-dist/tex/latex/amsmath/amsgen.sty)) (d:/texlive/2024/texmf-dist/tex/latex/amsmath/amsbsy.sty) (d:/texlive/2024/texmf-dist/tex/latex/amsmath/amsopn.sty)) (d:/texlive/2024/texmf-dist/tex/latex/unicode-math/unicode-math.sty (d:/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty (d:/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-luatex.def)) (d:/texlive/2024/texmf-dist/tex/latex/unicode-math/unicode-math-luatex.sty (d:/texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty) (d:/texlive/2024/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty) (d:/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.sty (d:/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty (d:/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty) (d:/texlive/2024/texmf-dist/tex/latex/fontspec/fontspec.cfg))) (d:/texlive/2024/texmf-dist/tex/latex/base/fix-cm.sty (d:/texlive/2024/texmf-dist/tex/latex/base/ts1enc.def)) (d:/texlive/2024/texmf-dist/tex/lualatex/lualatex-math/lualatex-math.sty (d:/texlive/2024/texmf-dist/tex/latex/etoolbox/etoolbox.sty)) (d:/texlive/2024/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex))) (d:/texlive/2024/texmf-dist/tex/generic/babel/babel.sty (d:/texlive/2024/texmf-dist/tex/generic/babel/luababel.def) (d:/texlive/2024/texmf-dist/tex/generic/babel/luababel.def (d:/texlive/2024/texmf-dist/tex/luatex/luatexbase/luatexbase.sty (d:/texlive/2024/texmf-dist/tex/luatex/ctablestack/ctablestack.sty))) (d:/texlive/2024/texmf-dist/tex/generic/babel-english/english.ldf)) (d:/texlive/2024/texmf-dist/tex/generic/babel/locale/en/babel-english.tex) (d:/texlive/2024/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-hi.tex UTF-8 Hindi hyphenation patterns (d:/texlive/2024/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-hi.tex)) No file noto-font-problem.aux. Package babel Info: The following font families will use the default (babel) settings for all or some languages: (babel) * \sffamily = NotoSans(0) (babel) "name:Noto Sans:mode=node;script=latn;language=dflt;+tlig ;" (babel) * \ttfamily = lmtt (babel) [lmmono10-regular]: (babel) There is nothing intrinsically wrong with it, but (babel) 'babel' will no set Script and Language, which could (babel) be relevant in some languages. If your document uses (babel) these families, consider redefining them with \babelfont. (babel) Reported on input line 15. ! error: (linebreak): invalid list tail, probably missing glue ! ==> Fatal error occurred, no output PDF file produced! Update: This doesn't compile with Noto Sans Devanagari either.

  • How to achieve a ragged-right text that alternates longer and shorter lines symmetrically?
    by TypographyConnoisseur on April 19, 2025 at 11:07 am

    This was posted in reddit: https://www.reddit.com/r/typography/comments/1f9v2uc/how_is_this_kind_of_alignment_of_text_called_its/ Is there any way to achieve this in LuaLatex automatically?

  • Align array elements by ones digit
    by Jasper on April 19, 2025 at 12:11 am

    I am making arrays of numbers. How can I align them automatically by the ones digit? I understand that this won't work for arrays with math expressions in them, but I think it would be more legible for arrays which contain only decimal numbers. \documentclass{article} \begin{document} I want to align the numbers in the following array by the 1's digit, which I can't deem to accomplish using column specifiers. \[ \begin{array}{rr} -1 & 12.009 \\ 98 & -98 \end{array} \] like this, but without the phantoms: \[ \begin{array}{rr} -1 & 12.009 \\ 98 & -98\phantom{.009} \end{array} \] \end{document}

  • TeX for Baire category iterative sequence construction
    by D.R on April 18, 2025 at 6:12 pm

    When I teach the Baire category theorem, I write on the board the following diagram: I would like to have a TeX version of this diagram. The easiest possible solution would be with arrays, but then I can’t get the long underbraces and diagonal $\in$ symbols. Maybe this requires tikz? EDIT: this is what I managed to cook up with the help of some online tools and a lot of fiddling around. If anyone has a cleaner or better looking solution, I'm all ears. \documentclass{article} \usepackage{tikz} \usepackage{amsmath} \usepackage{amssymb} \usepackage{xcolor} \usetikzlibrary{decorations.pathreplacing, calc} \begin{document} \begin{tikzpicture}[x=1cm, y=-0.6cm, font=\footnotesize] % Constants \def\tab{0.7} \def\colstart{0} \def\rowskip{4} % distance in y between groups \def\subsetx{\colstart+6*\tab} % Top row \node[anchor=west] at (\colstart,0) {$V \qquad \cap U_1$}; \node[anchor=west] at (\subsetx,0) {$\subseteq V \cap U_1$}; % Underbrace \draw[decorate,decoration={brace,mirror,amplitude=5pt}] ($(0.0,0.3)$) -- ($(1.75,0.3)$); % Group Loop \foreach \n in {1,2,3} { \pgfmathsetmacro{\xbase}{\colstart + (\n)*\tab} \pgfmathsetmacro{\ybase}{(\n-1)*\rowskip + 1} % Vertical chain \node[anchor=west] at (\xbase,\ybase) {$\rotatebox[origin=c]{270}{$\supseteq$}$}; \node[anchor=west] at (\xbase,\ybase+1) {$\overline{B}_{\n}$}; \node[anchor=west] at (\xbase,\ybase+2) {$\rotatebox[origin=c]{270}{$\supseteq$}$}; \node[anchor=west] at (\xbase,\ybase+3) {$B_{\n} \qquad \cap U_{\the\numexpr\n+1\relax}$}; % Slanted x_n \node[red, rotate=30] at (\xbase-0.2,\ybase+3.4) {$x_{\n} \in $}; % Underbrace — only if not last group \ifnum\n<3 \draw[decorate,decoration={brace,mirror,amplitude=5pt}] (\xbase+0.0,\ybase+3.3) -- (\xbase+1.75,\ybase+3.3); \fi % Explicit intersection on RHS \edef\intersection{V} \foreach \k in {1,...,\the\numexpr\n+1\relax} { \xdef\intersection{\intersection\ \cap\ U_{\k}} } \node[anchor=west] at (\subsetx,\ybase+3) {$\subseteq \intersection$}; % Green arrow \draw[->, thick, green!70!black] (\xbase+0.6,\ybase+1.1) -- ++(0,-1.5) -- (\colstart+7*\tab,\ybase-0.4); \fill[green!70!black] (\xbase+0.6,\ybase+1.1) circle (2pt); } % Final line \pgfmathsetmacro{\finaly}{3*\rowskip + 5} \node[red] at (\colstart+4*\tab,\finaly) {$x_\infty$}; % Align the subseteq symbol with the others \node[anchor=east] at (\subsetx,\finaly) {$\in \overline{B}_n$}; \node[anchor=west] at (\subsetx,\finaly) {{\color{green!70!black}{$\subseteq V \cap U_1 \cap U_2 \cap \dots \cap U_n$}} $\quad \implies x_\infty \in V \cap \bigcap_{n=1}^\infty U_n$}; % Red path from x_1 to x_infty \draw[->, red, thick] (\colstart+1*\tab-0.45, 4.75) -- (\colstart+4*\tab-0.45, 1+4*4); \end{tikzpicture} \end{document}

  • Is it possible to set the scale of predefined TikZ patterns?
    by Ferrous1 on April 18, 2025 at 5:53 pm

    Predefined TikZ patterns have always worked quite well for me, with one exception: I could never figure out how to set a specific "scale" or "zoom factor", so to say. Currently, I am creating graphs with shapes that span over the better part of an A4 page's width, hence in some cases, the provided patterns like north west lines are visually too dense. The following straightforward sketch visualizes what I would like to achieve, ideally without needing to create a pattern from scratch: MWE: \documentclass[margin=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{shapes,patterns} \begin{document} \begin{tikzpicture} \draw[pattern=north east lines] (0,0) rectangle ++(4,4); \end{tikzpicture} \end{document}

  • Unable to get this chemfig
    by Karthick S on April 18, 2025 at 5:37 pm

    I have been trying to generate the following image for the last 5 hours without success: . Here is what I have till now: \documentclass{exam} \usepackage{amsmath} \usepackage{chemfig} \usepackage[version=4]{mhchem} \usepackage{graphicx} \usepackage[english]{babel} % If your document is in English \usepackage[utf8]{inputenc} % Make sure you have this \usepackage{tikz} \usetikzlibrary{positioning} %\usepackage{exam} % Uncomment if you want to use the exam class features \renewcommand{\thequestion}{A\arabic{question}} % Format as A<number> \renewcommand{\questionlabel}{\thequestion.} % Print A<number>. (Add the dot back) \begin{document} \begin{questions} \question \begin{parts} \part \begin{tikzpicture}[ node distance=2.5cm and 3.5cm, every node/.style={font=\small} ] % Compound P \node (P) {\chemfig{HO-[:0]-*6(=--(-NH_2)=-=)}}; \node[below=of P] (Q) {\chemfig{HO-[:0]-*6(=-(-N^{+}\equiv N^{-})-=-=)}}; \node[below=of Q] (S) {\chemfig{HO-[:0] -*6(=-- (-N=[:60]N -*6(= (-[::60]*6(=-= ( -OH )--=- ) )-=-=- ) )=-= ) }}; % Arrows \draw[->] (P) -- (Q) node[midway,right,xshift=1.2cm] {\chemfig{NaNO_2 + HCl}}; \draw[->] (Q) -- (S) node[midway,right,xshift=1.2cm] {\chemfig{NaOH + compound R}}; % Labels \node[left=1cm of P] {compound P}; \node[left=1cm of Q] {intermediate compound Q}; \node[left=1cm of S] {compound S}; \node[right=2.5cm of P] {First step in the synthesis:}; \node[right=2.5cm of Q] {Second step in the synthesis:}; \end{tikzpicture} \end{parts} \end{questions} \end{document} This generates the following image: Please help.

  • If I defined a command with optional arguments after calling lists of figures/tables, how can I use this command in a caption without causing errors?
    by Jonathan on April 18, 2025 at 4:54 pm

    I would like to be able to use commands with default arguments in captions of figures/tables without causing an error in \listoftables or \listoffigures. For example, the following code causes an error stating "Undefined control sequence.": \documentclass{article} \begin{document} \listoftables \newcommand{\acommand}[1][X]{b(#1)} \begin{table} \caption{I'm using a command $\acommand$ in a caption.} \end{table} I'm using the command again $\acommand[Y]$. \end{document} This code does not generate any errors if the optional argument is removed from the definition of \acommand (and any calls). Things like \protect and supplying the argument doesn't make any difference. Anyone know how to avoid this error? Edit: Sorry I forgot to mention that the definition of \acommand is deliberately placed after the call to \listoftables. In reality I'm managing a very large document made of many subdocuments and to keep things organised, its extremely helpful to have my commands defined in the relevant subdocuments/subsections instead of defining everything before the \listoftables which must appear near the start of the document. This works for any commands that don't have optional arguments. You can test this by removing the optional argument in the MWE above and see that the error disappears. I'm hoping there is a way that I can remove the error while retaining optional arguments.

  • tikz-qtree tree moves to next page even with sufficient space
    by cs_to_cs on April 17, 2025 at 11:13 am

    I am creating a handout that includes some trees created using tikz-qtree, and I'm having two inter-related issues: one of unnecessary white space and one where a potential solution behaves unexpectedly. Sometimes, a tree ends up moved to the next page even though there's enough space for it to fit, leaving a lot of white space unnecessarily. I can force the tree to fill that space with something like \vspace{-6em}, but I don't understand why it works like it does. First, if you only do -1em for example, up to 5, nothing changes, and then with -6em, the tree does move to the previous page to fill the white space BUT too high, overlapping the text, like this (notice the "1" at the bottom where the page ends): I understand that as you move something up it will eventually overlap text above where it would have been. What I don't understand is why 1 more em is just enough to move the tree even though the space under the tree, once it moves, is clearly much more then 1em. In summary, (A) why does the tree move to the next page when there is enough space for it and (B) why does \vspace not work until some tipping point, overlapping the text? MWE (BUT recall that you need to adjust \vspace{-2em}to see what happens with the tree) \documentclass{article} \usepackage{tikz} \usepackage{tikz-qtree} \usepackage{tikz-qtree-compat} \usepackage{amsmath} \usepackage{amssymb} \begin{document} \section{Some heading} \begin{itemize} \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \end{itemize} \section{Another heading} \begin{itemize} \item Some text. \vspace{-2em} \end{itemize} \begin{tikzpicture}[baseline]\tikzset{every tree node/.style={align=center,anchor=north}} \Tree [.CP \phantom{Test} [.C' \node(C){C\\$\varnothing$}; [.TP [.\node(SpecTP){DP}; ] [.T' \node(T){T}; [.VoiceP \phantom{Test} [.Voice' \node(Voice){Voice\\t_{\text{pass}}}; [.VP [.V' \node(V){V}; \node(Object){t_{\text{DP}}}; ] ] ] ] ] ] ] ] \draw[->] (Voice) to[out=240,in=240,looseness=1.9] (T); \draw[->] (Object) to[out=240,in=200,looseness=1.2] (SpecTP); \end{tikzpicture} \end{document}

  • Tipauni problem with accent marker on LaTex
    by Randomname on April 17, 2025 at 10:24 am

    I'm using tipauni package to write IPA symbols, but there is a problem with the accent marker. I wanted to write /aˈʧitə/, but as you can see in the following image, the ' just goes above the a. Tipa doesn't give me this problem, but if possible I'd want to use tipauni. Another example: the first one is right, the second is not (I guess the ' can only go above "short" letters"): I'm using LuaLaTex, but the problem is the same with XeLaTex too. MWE to reproduce the output of the first image (run with LuaLaTeX): \documentclass{article} \usepackage{tipauni} \begin{document} \textipa{/aˈʧitə/} \end{document}

  • Tagged PDF & float here [H]
    by LeO on April 17, 2025 at 7:46 am

    With the new tagging possibilities a "figure" should reside within a figure tag. To my understanding all the figure environments are float environments. Nevertheless I need to display a figure in the same text flow as it "set" - so basically I need to place the figure Here. There have been several threads with the discussion how to solve the this topic - without tagging enabled. One of the most common is to use the package float with the option H. A very simplistic MWE (for demonstration purpose only) \DocumentMetadata{ pdfstandard = ua-2, pdfversion = 2.0, testphase = latest, lang=de, } \documentclass{article} \usepackage[showframe]{geometry} \usepackage{float} \usepackage{xcolor, kantlipsum} \begin{document} \kant[4-6] \begin{figure}[H] \framebox[\textwidth]{ \begin{minipage}{0.9\textwidth} \kant[64] \end{minipage} } \caption{quick caption} \end{figure} \underline{\color{red} Some text inbetween} \kant[64-67] \end{document} The red underlined text should appear below the figure. As mentioned on the compatibility site float is incompatible with the option [H]. When I compile the above code I get Package tagpdf Warning: Parent-Child 'Document/pdf2' --> 'Caption/pdf2'. (tagpdf) Relation is not allowed (struct 2, /Document --> (tagpdf) struct 15) on line 21 because the caption is not properly tagged. I've read different solutions but remain unclear if they work generally. At least for this scenario [h!] won't help. How to force a figure to be placed "Here" and have a valid tagged PDF?

  • Automatize space insertion
    by Vincent Krebs on April 17, 2025 at 12:47 am

    I used to have many commands programmed to insert a space at the very beginning, except if the starred version is used instead. I have since then automatized the space insertion by using a smart \coolspace command that only inserts a space when there is something before. This smart command works in most cases, except in the specific situation where we are inside a list AND within an argument (such as one of \textbf{} -- see MWE). Is there a solution to improve the command, i.e. make it NOT insert a space in this case? MWE \documentclass{article} \usepackage{enumitem} \DeclareRobustCommand{\coolspace}{% \ifhmode \ifnum\lastnodetype=1 \else \unskip\space% \fi% \fi} \parindent0ex \begin{document} This\coolspace correctly produces a space between \textit{this} and \textit{correctly}. \coolspace No space at the beginning of a line, good. \textbf{\coolspace Even if it's part of the content of an argument.} \begin{itemize}[label=--] \item This\coolspace correctly produces a space between \textit{this} and \textit{correctly} \item\coolspace No space at the beginning of a line, good. \item\textbf{\coolspace It's an argument, a space is incorrectly produced.} \end{itemize} \end{document}

  • Reproduce the image using TikZ
    by Alberto Belmonte on April 16, 2025 at 7:40 pm

    I'm working on some school notes, but my skills aren't enough to create something similar to the image. It's something much more clumsy. I'm sure that with TikZ something very similar can be done. Image: My code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{tikzmark, shapes.geometric, shapes.arrows, fit, calc, positioning} \begin{document} \begin{tikzpicture} % Ecuación base \node[draw=none, font=\large] (equation) at (0,0) {$\sqrt[n]{a} = b$}; % Etiqueta de Índice (n) \node[draw=red, thick, rectangle, rounded corners, inner sep=5pt, align=center, color=red] (index) at (-2, 1.5) {Índice}; \draw[thick, red, ->] (index.east) -- (equation.north west); % Etiqueta de Radicando \node[draw=blue, thick, rectangle, rounded corners, inner sep=5pt, align=center, color=blue] (radicando) at (-2, 0) {Radicando}; \draw[thick, blue, ->] (radicando.east) -- (equation.west); % Etiqueta de Raíz \node[draw=green, thick, rectangle, rounded corners, inner sep=5pt, align=center, color=green] (raiz) at (2, 0) {Raíz}; \draw[thick, green, ->] (raiz.west) -- (equation.east); \end{tikzpicture} \end{document}

  • How to use minted for highlighting two languages in one code block (LuaLaTeX)
    by Youra_P on April 16, 2025 at 5:50 pm

    Minted loads code from a file. The file contains code in two languages ​​TeX and Lua. I found this but it doesn't work: minted - how to highlight html also, when language "twig" is selected How to highlight both languages in one code block? MWE: % !TeX program =lualatex % !TeX encoding = utf-8 %----------------- \documentclass{article} \usepackage[newfloat]{minted} \usepackage{etoolbox} \setminted{xleftmargin=0.5cm, linenos, numbersep=5pt, breaklines, breakanywhere, frame=single, framesep=1ex, fontsize=\small} \usepackage{luacode} \begin{luacode*} -- text comment function injcount(s) local matches = {} local count = 0 local s_before_percent = s:match("^(.-)%%") or s:match("^(.-)$") if s_before_percent then s_before_percent, count = s_before_percent:gsub("put[ft]%{(.-)%}", function(match) if string.find(match, layer) then totf = totf + 1 else return match end return "" end) end return s end \end{luacode*} \makeatletter \newenvironment{code}{}{} \SetupFloatingEnvironment{listing}{name=сode} \makeatother \begin{document} Listing usage example: \begin{code} \inputminted{tex}{\jobname.tex} \end{code} \end{document}

  • Change page margin for first page within environment
    by Dave on April 16, 2025 at 5:27 pm

    I have created a custom environment wherein the first page on which the environment starts should have a modified top margin, for example to insert a picture (see gray rectangle). All following pages should go back to the original set geometry. Setting the new geometry is no hassle, but restoring the original geometry simply does not work. I appreciate all help! My goal: Status quo: My code: \documentclass[a4paper,11pt]{book} \usepackage[ a4paper, portrait, heightrounded, showframe, inner = 20.0mm, outer = 20.0mm, top = 30.0mm, bottom = 40.0mm, nohead, nomarginpar, footskip = 20.0pt, footnotesep = 7.0pt, ]{geometry} \pagestyle{empty} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{expl3} \ExplSyntaxOn \NewDocumentEnvironment{custom}{}{ \clearpage \newgeometry{ heightrounded, inner = 20.0mm, outer = 20.0mm, top = 99.0mm, bottom = 40.0mm, } \begin{tikzpicture}[remember ~ picture, ~ overlay] \filldraw[fill = gray] (current ~ page.north ~ west) rectangle ++(\paperwidth, -99mm); \end{tikzpicture} }{} \ExplSyntaxOff \usepackage{lipsum} \begin{document} \begin{custom} \lipsum \end{custom} % \begin{custom} % \lipsum % \end{custom} \end{document}

  • Adobe Acrobat not displaying inline image
    by Slurp on April 16, 2025 at 2:10 pm

    I've been playing around with pdfTeX primitives lately, and I'm trying to insert an inline image (of a smiley). I have the following code: \pdfcompresslevel=0 \catcode`@=11 \nopagenumbers \centerline{\hbox to100pt{\vrule width\z@ height100pt depth\z@% \pdfliteral{ .996264 0 0 .996264 0 0 cm 100 0 0 100 0 0 cm BI /BPC 8 % each value is a byte /CS /DeviceRGB % interpret colors as RGB /F [ /AHx ] % the stream is given in ASCII representing hexadecimal values /W 9 % each line is given by 9 samples /H 9 % 9 lines ID ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ff0000 ff0000 ffffff 00ff00 00ff00 ffffff 00ff00 00ff00 ffffff ff0000 ff0000 ffffff 00ff00 00ff00 ffffff 00ff00 00ff00 ffffff ff0000 ff0000 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ff0000 ff0000 ffffff 0000ff ffffff ffffff ffffff 0000ff ffffff ff0000 ff0000 ffffff ffffff 0000ff 0000ff 0000ff ffffff ffffff ff0000 ff0000 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 EI }\hfil}} \bye (Compiled with pdftex) As-is, no errors are reported by either ghostscript or Adobe Acrobat Pro preflight, but no image shows up on the page. But an image does show up if you use SumatraPDF (or most other viewers I assume, Acrobat is the only one which doesn't seem to show the image). Though if you run ghostscript (gs -dDEBUG file.pdf > log.txt) I noticed that nothing is printed after ID, which I assume is the issue. Another thing, if you surround the inline image with q...Q, Acrobat preflight complains about unbalanced q...Qs (too many qs). Looking at this with ghostscript, I see the following: q 0.996264 0 0 0.996264 0 0 cm 100 0 0 100 0 0 cm BI /BPC 8 /CS /DeviceRGB /F [ /AHx ] /W 9 /H 9 ID Q So (a) none of the image data is printed after ID, and (b) the Q is placed after the ID, where the image data should be. So I assume it's being read as the image data and that's why there's unbalanced q/Qs? Finally, if you remove \nopagenumbers, Acrobat preflight reports "invalid operator(s)" for the cm operator, which I was able to determine is the cm operator after the image, which places translates the CTM to place the page number. I have consulted the PDF standard, and I am unsure why this is happening. Any help would be greatly appreciated, thank you!

  • Advantages and disadvantages of \text_uppercase:n vs \MakeUppercase
    by David Purton on April 16, 2025 at 1:18 pm

    When should I use \text_uppercase:n and when should I use \MakeUppercase? I assumed that \text_uppercase:n would always be more reliable, but I found it fails to deal with \today when a babel language is loaded in a modern way. Whereas \MakeUppercase succeeds in such a case. Consider the following MWE: \documentclass{article} \usepackage[australian, provide*=*]{babel} % \usepackage[australian]{babel} % ← works \begin{document} \MakeUppercase \today \ExplSyntaxOn \text_uppercase:n \today \end{document}

  • Evaluating a function
    by azetina on April 15, 2025 at 4:53 pm

    Consider the following MWE: \documentclass{article} \usepackage{amsmath} \usepackage{siunitx} \ExplSyntaxOn \NewDocumentCommand{\evalfunction}{O{} O{10} m } { \num[#1]{\fp_eval:n { trunc((sqrt(#3+4)-2)/#3,#2) }} %https://tex.stackexchange.com/a/197854/10898 } \ExplSyntaxOff \begin{document} \begin{center} \renewcommand{\arraystretch}{1.2} \begin{tabular}{|r|c|} \hline $x$ & $f(x)$ \\ \hline $0.1$ & \evalfunction{0.1} \\ $0.01$ & \evalfunction{0.01} \\ $0.001$ & \evalfunction{0.001} \\ $0.0001$ & \evalfunction{0.0001} \\ \hline \end{tabular} \end{center} \end{document} The desired output is as expected. I am seeking to create a generic way of calling a function locally instead of defining within a command. Note that the command \evalfunction only works for (sqrt(#3+4)-2)/#3. I would like this to be customizable. Something like \evalfunctiondefn[abc]{(sqrt(#3+4)-2)/#3} then call \evalfunction[abc]{0.1}. Also note \evalfunction{0.01} only shows 9 decimal places instead of 10.

  • Tagged PDF & Metadata
    by LeO on April 15, 2025 at 8:44 am

    I want to set metadata for Tagged PDFs but somehow this fails. I tried to narrow down the source of this issue and excluded all packages. Therefore I follow the example from Ulrike \DocumentMetadata{ lang=en, % testphase=latest, % pdfstandard=UA-2, } \documentclass{article} \ExplSyntaxOn \pdfmanagement_add:nnn{Info}{Title}{(My~other~Story)} \pdfmanagement_add:nnn{Info}{Author}{(Someone)} \ExplSyntaxOff \begin{document} aaa1 \end{document} It seems like as soon as the ua-2 is enabled the metatags are gone. pdfinfo clearly writes Custom Metadata: no Following Wiki I couldn't see a reason why MetaTags are not allowed. Is there a way to set the attributes? NOTE: Since its a MWE I focused on two attributes only. For real life I need additional attributes. Running on lualatex 1.22.0