Month
- Luatex - Coloring Harakaby Mario Fischer on March 4, 2026 at 6:08 am
I want to colour the harakat (diacritics) of a text in Pashto. I use Luatex, and I want to switch this function on and off. It should look like I tried this code: \documentclass{article} \usepackage{fontspec} \usepackage{xcolor} \usepackage{luacolor} \usepackage[bidi=basic]{babel} % Setup Arabic language \babelprovide[import, main]{arabic} % THE FIX: Use Renderer=Node instead of Harfbuzz \babelfont{rm}[Renderer=Node]{Amiri} % 1. The Lua Script \directlua{ harakat_attr_val = nil local luacolor_attr = luatexbase.attributes['luacolor'] local function color_harakat(head) if not harakat_attr_val then return head end for item in node.traverse_id(node.id("glyph"), head) do local char = item.char -- Unicode range for Arabic harakat (0x064B to 0x065F) -- and the superscript Alef (0x0670) if (char >= 0x064B and char <= 0x065F) or char == 0x0670 then node.set_attribute(item, luacolor_attr, harakat_attr_val) end end return head end % Add the filter so it runs before the font shaper luatexbase.add_to_callback("pre_linebreak_filter", color_harakat, "color_harakat") } % 2. Custom command to safely set the Harakat color \makeatletter \newcommand{\setHarakatColor}[1]{% \begingroup \color{#1}% \directlua{ harakat_attr_val = tex.attribute[luatexbase.attributes['luacolor']] }% \endgroup } \makeatother \begin{document} \begin{center} \Huge % Tell LuaTeX to color all following harakat Red \setHarakatColor{red} بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ \vspace{1cm} % Switch to blue! \setHarakatColor{blue} بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ \end{center} \end{document} But it is not coloring. What might be the problem, or is there an easy option in Luatex?
- TikZ: How to add a node where a path gets clippedby Edoardo Serra on March 3, 2026 at 3:07 pm
I am designing a square (or “squarish” actually) map protractor in TikZ. So far, I have managed to draw the degree ticks along the four sides by clipping radial lines between two closed paths using the even odd rule like I saw in this answer. The ticks are generated in a \foreach loop. To avoid drawing long ticks on top of short ones, I separated them into two loops using a conditional test. I am not sure whether this separation is actually necessary for correct SVG export/printing, but that is how I implemented it. Below is a MWE: \documentclass[tikz]{standalone} %,convert={outfile=\main.svg} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{intersections, pgfplots.fillbetween} \pgfdeclarelayer{pre main} \pgfdeclarelayer{main} \pgfsetlayers{pre main, main} \usetikzlibrary{shapes} \begin{document} %all of this is needed to easily clip between two closed paths using even odd rule \makeatletter \def\@appendnamedsoftpath#1{% \pgfsyssoftpath@getcurrentpath\@temppatha \expandafter\let\expandafter\@temppathb\csname tikz@intersect@path@name@#1\endcsname \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\@temppatha\expandafter\expandafter\expandafter{\expandafter\@temppatha\@temppathb}% \pgfsyssoftpath@setcurrentpath\@temppatha } \def\@appendnamedpathforactions#1{% \pgfsyssoftpath@getcurrentpath\@temppatha \expandafter\let\expandafter\@temppathb\csname tikz@intersect@path@name@#1\endcsname \expandafter\def\expandafter\@temppatha\expandafter{\csname @temppatha\expandafter\endcsname\@temppathb}% \let\tikz@actions@path\@temppatha } \tikzset{ use path for main/.code={% \tikz@addmode{% \expandafter\pgfsyssoftpath@setcurrentpath\csname tikz@intersect@path@name@#1\endcsname }% }, append path for main/.code={% \tikz@addmode{% \@appendnamedsoftpath{#1}% }% }, use path for actions/.code={% \expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions\expandafter\let\expandafter\tikz@actions@path\csname tikz@intersect@path@name@#1\endcsname}% }, append path for actions/.code={% \expandafter\def\expandafter\tikz@preactions\expandafter{\tikz@preactions \@appendnamedpathforactions{#1}}% }, use path/.style={% use path for main=#1, use path for actions=#1, }, append path/.style={% append path for main=#1, append path for actions=#1 } } \makeatother \begin{tikzpicture} \pgfmathsetmacro\bigside{7} \pgfmathsetmacro\smallsidedelta{0.5} %cuts \draw[rounded corners=12pt, name path=outside] (0,0) rectangle (\bigside,\bigside); \draw[dotted, rounded corners=12pt, name path=inside] (\smallsidedelta,\smallsidedelta) rectangle (\bigside-\smallsidedelta,\bigside-\smallsidedelta); %remove before cutting or printign. Just as reference grid %backside print \tikzfillbetween[of=inside and outside] {white}; %print on transparent plastic so this is needed for better readability %frontside print \pgfmathsetmacro\degreesmallticksize{0.2} \pgfmathsetmacro\degreemidticksize{0.35} \pgfmathsetmacro\outerradius{sqrt(2*\bigside/2*\bigside/2)} \path[rounded corners=12pt, name path=degrees short] (\degreesmallticksize,\degreesmallticksize) rectangle (\bigside-\degreesmallticksize,\bigside-\degreesmallticksize); \path[rounded corners=12pt, name path=degrees mid] (\degreemidticksize,\degreemidticksize) rectangle (\bigside-\degreemidticksize,\bigside-\degreemidticksize); \begin{scope} [even odd rule] %small ticks \clip[use path=outside, append path=degrees short]; \foreach \deg in {0, ..., 359} { \pgfmathsetmacro\degmod{mod(\deg,5)} \pgfmathtruncatemacro{\itest}{ifthenelse(\degmod==0,1,0)} \ifnum\itest=0 \draw[thin] (\bigside/2,\bigside/2) -- ({\bigside/2+\outerradius*cos(\deg)},{\bigside/2+\outerradius*sin(\deg)}); \fi } \end{scope} %had to add a second scope and for loop since the clipped area is different \begin{scope} [even odd rule] %mid ticks \clip[use path=outside, append path=degrees mid]; \foreach \deg in {0, ..., 359} { \pgfmathsetmacro\degmod{mod(\deg,5)} \pgfmathtruncatemacro{\itest}{ifthenelse(\degmod==0,1,0)} \ifnum\itest=1 \draw[thick] (\bigside/2,\bigside/2) -- ({\bigside/2+\outerradius*cos(\deg)},{\bigside/2+\outerradius*sin(\deg)}); \fi } \end{scope} \end{tikzpicture} \end{document} And the output is the following: I would now like to add a label at the inner end of each thick (5°) tick, displaying the corresponding degree value (0–355), like this: Now a few nuances: The numbers must always face towards the inside, with the exception, if possible, of the bottom row of numbers from 135° to 225°. When numbers get big, they don't have enough space to fit unless the labels become too small to read (actual printing size of the protractor will be something like 7x7 or 8x8cm). So they need to be shifted in such a way that they fit. 355 in the provided image is a clear example of what I mean. I can consider shifting them radially as well, but they need to stay to the outside of the dotted line, which I can make a little smaller. I really don't know where to start and didn't manage to find anything online. Thank you for your time!
- tabularray - make talltblr caption mirror other captionsby user20478285 on March 3, 2026 at 12:13 am
\documentclass{article} \usepackage[font=small, labelfont=bf, format=hang]{caption} \usepackage{tabularray} \usepackage{tblr-extras} \UseTblrLibrary{amsmath, booktabs, caption} \begin{document} \begin{table}[h] \centering \begin{talltblr}[caption={A talltblr table.}]{colspec={cc}} \toprule a & b\\ \midrule x & y\\ \bottomrule \end{talltblr} \end{table} \end{document} Using the code above, I get the following result for my talltblr (i.e. the caption width is limited to the table width). I tried the approach from here: \documentclass{article} \usepackage[font=small, labelfont=bf, format=hang]{caption} \usepackage{tabularray} \usepackage{tblr-extras} \UseTblrLibrary{amsmath, booktabs, caption} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DefTblrTemplate{firsthead}{caption}{% \makebox[\tablewidth]{\parbox{\columnwidth}{% \UseTblrTemplate{caption}{normal}% }}% } \SetTblrTemplate{firsthead}{caption} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{table}[h] \centering \caption{A regular table. A regular table. A regular table. A regular table. A regular table. A regular table. A regular table. A regular table. A regular table.} \begin{tabular}{cc} \toprule a & b\\ \midrule x & y\\ \bottomrule \end{tabular} \end{table} \begin{table}[h] \centering \caption{A tblr table. A tblr table. A tblr table. A tblr table. A tblr table. A tblr table. A tblr table. A tblr table. A tblr table. A tblr table. A tblr table.} \begin{tblr} { colspec={cc} } \toprule a & b\\ \midrule x & y\\ \bottomrule \end{tblr} \end{table} \begin{table}[h] \centering \begin{talltblr} [ caption={A talltblr table. A talltblr table. A talltblr table. A talltblr table. A talltblr table. A talltblr table. A talltblr table. A talltblr table.} ] { colspec={cc} } \toprule a & b\\ \midrule x & y\\ \bottomrule \end{talltblr} \end{table} \end{document} Now the caption has the right width, but it is too close to the table itself. Also, the caption font is too big and the label is not bold, which I can fix / hack if I add \SetTblrStyle{caption-tag}{font=\small\bfseries} \SetTblrStyle{caption-text}{font=\small} but I'm not sure if this is the way to go (and it does not fix the issue of the caption touching the table). I also tried to have a look at the default caption definitions myself in the source code but I just don't understand even remotely enough of LaTeX3). Edit for clarity: I don't need to be able to control table, talltblr, and tblr with \captionsetup, I am rather looking for a way to get the same consistent captions for figure, table, tblr and talltblr environments in my document. I realise this is not easy, especially since the different caption style for talltblr is apparently a feature: I don't think it is a bug. In many aspects, tabularray is different from traditional tables https://github.com/TeXackers/tabularray/issues/255#issuecomment-1142833319)
- Improving the visibility of a curve in a 3D PGFPlots surfaceby Octavius on March 2, 2026 at 4:50 pm
In the left-hand figure, I would like to improve the visualization so that the red curve is more clearly visible. \documentclass[12pt,b5paper,twoside,openany]{book} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{amsmath,amssymb,amsfonts,amsthm} \usepackage{graphicx} \usepackage{xcolor} \usepackage{tikz} \usepackage{tikz-3dplot} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \hypersetup{colorlinks=true,linkcolor=black,citecolor=black} \newtheorem{example}{Example} \setlength{\parindent}{0pt} \begin{document} \begin{example} Consider the function \[ f(x,y)=x^2+y^2, \] the point \[ c=(0,0), \] and the direction \[ u=(1,0). \] To study the variation of $f$ at $c$ in the direction $u$, we define the one-variable function \[ F(t)=f(c+tu). \] In this case, \[ c+tu=(t,0), \] and therefore \[ F(t)=f(t,0)=t^2. \] Thus, when we move away from $c$ in the direction $u$, the values of $f$ vary according to the quadratic function $F(t)=t^2$. The directional derivative of $f$ at $c$ in the direction $u$ is given by \[ f'(c;u)=F'(0). \] Since \[ F'(t)=2t, \] we obtain \[ f'(c;u)=F'(0)=0. \] \end{example} \bigskip \begin{center} \begin{tikzpicture} % --- SURFACE --- \begin{axis}[ at={(0,0)}, anchor=origin, view={120}{25}, axis lines=center, axis line style={->}, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}, domain=-2:2, y domain=-2:2, samples=30, samples y=30, width=8cm, height=8cm ] % Surface z = x^2 + y^2 \addplot3[surf, opacity=0.4] {x^2+y^2}; % Curve corresponding to F(t) \addplot3[very thick, red, domain=0:1.2, samples=100] ({x},{0},{x^2}); \end{axis} % --- GRAPH OF F(t) --- \begin{axis}[ at={(7cm,0)}, anchor=origin, axis lines=middle, axis line style={->}, xlabel={$t$}, ylabel={$F(t)$}, domain=-1.5:1.5, samples=200, width=7cm, height=6cm ] \addplot[very thick, red] {x^2}; \node at (axis cs:1,1) [red, anchor=west] {$F(t)=t^2$}; \end{axis} \end{tikzpicture} \end{center} \end{document}
- Disable stretching between words while using babel for Thaiby p_pattedd on March 2, 2026 at 8:04 am
When typing a document in Thai with babel (using XeLaTeX via MikTeX), sometimes it outputs with these spaces between words, for example: MWE: \documentclass[12pt,a4paper]{article} \usepackage[no-math]{fontspec} \usepackage[thai,provide=*]{babel} \babelfont[thai]{rm}[Scale=1.33333]{TH Sarabun New} \renewcommand\baselinestretch{1.4} \begin{document} เดิมแผ่นดินเมืองจีนทั้งปวงนั้น เปนสุขมาช้านานแล้วก็เปนศึก ครั้นศึกสงบแล้วก็เปนสุข มีพระมหากษัตริย์ทรงพระนามพระเจ้าจิวบูอ๋อง แลพระวงศ์ได้เสวยราชย์ต่อ ๆ ลงมาเปนหลายพระองค์ ได้ความสุขมาถึงเจ็ดร้อยปี จึงมีผู้ตั้งแขงเมืองถึงเจ็ดหัวเมือง ครั้งนั้นพระเจ้าจิ๋นอ๋องได้เสวยราชย์ในเมืองจิ๋นก๊กให้ไปตีเอาหัวเมืองทั้งเจ็ดนั้น เข้าอยู่ในอาณาจักรพระเจ้าจิ๋นอ๋องทั้งสิ้น ครั้นอยู่มาพระเจ้าจิ๋นอ๋องเสียแก่ฮั่นฌ้อ แล้วฮั่นโกโจกับฮั่นฌ้อรบกัน จึงได้ราชสมบัติแก่ฮั่นโกโจ ฮั่นโกโจแลพระราชวงศ์ได้เสวยราชสมบัติต่อ ๆ มาในแผ่นดินจีนนั้นถึงสิบสององค์ มีขุนนางคนหนึ่งชื่ออองมังเปนขบถชิงเอาราชสมบัติได้ เปนเจ้าแผ่นดินอยู่สิบแปดปี แล้วจึงมีหลานพระเจ้าฮั่นโกโจชื่อฮั่นกองบู๊จับอองมังฆ่าเสียชิงเอาราชสมบัติได้เสวยราชย์สืบวงศ์มาสิบสององค์ พระองค์ได้เสวยราชย์ที่สุดนั้น ทรงพระนามพระเจ้าเหี้ยนเต้ จึงแตกเปนสามเมือง ภาษาจีนเรียกว่า สามก๊ก \end{document} How to stop LaTeX from doing this? (I have read babel-thai documentation, but none of the macros seems to work.)
- How to change "python" language style of listings packageby Syvshc on March 1, 2026 at 3:28 pm
I want to define my own style of Python, so I write \documentclass{article} \usepackage{listings, xcolor} \lstset { basicstyle = \ttfamily\small, frame = leftline, framerule = 1pt, } \lstdefinelanguage{python}{ morekeywords = {python, red}, keywordstyle = {\bfseries\color{red}}, rulecolor = {\color{red}}, } \begin{document} \begin{lstlisting}[language=python] python, red \end{lstlisting} \end{document}% after compiling with texlive 2025, I got: It did not work. I thought it might be the problem with the default settings of listings.sty package, i.e. lstlang1.sty. However, I can change the style of matlab language: \documentclass{article} \usepackage{listings, xcolor} \lstset { basicstyle = \ttfamily\small, frame = leftline, framerule = 1pt, } \lstdefinelanguage{python}{ morekeywords = {python, red}, keywordstyle = {\bfseries\color{red}}, rulecolor = {\color{red}}, } \lstdefinelanguage{Matlab}{ morekeywords = {Matlab, lime}, keywordstyle = {\bfseries\color{lime}}, rulecolor = {\color{red}}, } \begin{document} \begin{lstlisting}[language=python] python, red \end{lstlisting} \begin{lstlisting}[language=Matlab] Matlab, lime \end{lstlisting} \end{document}% The output is: I wonder why it happened and how I can actually change the style of "python" language. EDIT: I found that this does not work only on TexLive 2025; my version of listings is 76899, and it's cat-version is 1.11b. If I compile this file with 1.10a and TexLive 2024 on Overleaf, all things worked well. EDIT: I found that listings package is insensitive to the language name, Python, python, and PYTHon point to the same language
- Automatic italic for foreign wordsby Apothikon on March 1, 2026 at 2:06 pm
Foreign words or phrases inside a mostly monolingual document should usually be displayed in italic. How can this be achieved automatically using babel? I have produced the following code: \documentclass{article} \usepackage{lipsum} \usepackage[french, british, italian]{babel} % Font for the main language \babelfont{rm}{ebgaramond} % Font for foreign languages, inverting roman and italic \babelfont [french, british]{rm}{ebgaramond-Italic} \begin{document} MAIN LANGUAGE \lipsum[1] \vspace{1em} FOREIGN LANGUAGE \foreignlanguage{british}{\lipsum[1]} \end{document} However, I can see some problems in my approach: If I define new features for the font (ligatures, character variants...) I must repeat them for both the main and the foreign font; If I add new languages I must remember to add them to the list of foreign languages to which the italic must be applied. I am quite sure that the amazing babeltransform can easily make it more automatic.
- Reset counter in \newtheoremby Afonso Guerra on March 1, 2026 at 10:52 am
I'm trying to make a title with \newtheorem{case}{Caso} (My code is in Portuguese-Portugal) and it outputs Caso X. "X" being the next number. So here is the thing, I actually need to reset the "X" value, and I have tried the [theorem] parameter, but it doesn't work for me so can anyone help? Here is my code: \documentclass[12pt]{report} \usepackage[]{amsmath,amsthm,amssymb,amscd} \usepackage[a4paper,margin=25mm]{geometry} \usepackage{babel} \usepackage{pgfplots} \usepackage{multirow} \usepackage{booktabs} \usepackage{framed} \newtheorem{case}{Caso} \begin{document} \begin{case} Não conhecemos a distribuição de $X_1$ ou $X_2$, mas os tamanhos das amostras não apresentão assimetrias exageradas. \end{case} \begin{case} % Some text here % \end{case} % Reset the X value % \begin{case} % More text here, but with it saying "Caso 1." % \end{case} \end{document} If you want something else please tell me.
- How to produce an effect of bracket below with text?by Sunshine on March 1, 2026 at 5:29 am
I want to produce the bracket like this: \documentclass{article} \begin{document} There is a bracket below with text. \end{document}
- How can I calculate or approximate the intersection(s) or lack thereof of a line and an exponential curve using Lua?by Jasper on February 27, 2026 at 5:58 pm
How can I calculate or approximate the intersection(s) or lack thereof of a line and an exponential curve. My goal is to avoid using an approach which first tessellates curves into line segments, and tests each line segment pair. That is O(n^2). I want something which can scale. I think Lua is appropriate for this, based on evidence in the comments. \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \draw[->] (-2,0) -- (2,0); \draw[->] (0,-2) -- (0,e^2); \draw[domain=-2:2] plot (\x,e^\x); \draw[domain=-2:2] plot (\x,\x+1.5); % two intersections \draw[domain=-2:2] plot (\x,\x+1); % one intersection \draw[domain=-2:2] plot (\x,-\x+4.5); % one intersection \draw[domain=-2:2] plot (\x,\x); % zero intersections % My goal is to use pgfmath to calculate, or if % necessary iteratively approximate, the intersections % of these lines with the exponential curve. % If it is not easy in pgfmath, then I want a Lua-based solution. \end{tikzpicture} \end{document}
- Problem (warning message) with Calculator packageby ViToni on February 27, 2026 at 4:03 pm
This rather small document \documentclass{article} \usepackage{calculator} \newcommand{\myPerCent}[2]{% \DIVIDE{#1}{#2}{\sol}% \MULTIPLY{\sol}{100}{\sol}% \ROUND{\sol}{\sol}% \sol% } \begin{document} Computed \myPerCent{2441}{8667}.\par \end{document} produces this warning (I guess it's a warning and not an error as the PDF is finally built): (\end occurred when \ifdim on line 13 was incomplete) I have no clue how to solve the issue as the code looks ok at first glance, but it seems something is off here. How can I use the package in a proper way? (I'm quite happy I was able to identify the source for the warnings at least as the original document is rather large and I started looking into things like How to diagnose unclosed (incomplete) \iftrue or \ifnum? but somehow I didn't get me anywhere and I don't seem to know anything more than before...)
- Need a new Latex command for square bracketsby Ilia on February 27, 2026 at 1:38 pm
I've already encountered in this site complaints that in the standard font, the horizontal lines (serifs) in the image of square brackets are too short and difficult to visually distinguish. As a workaround, some suggest using overlapping "ceil" and "floor" symbols instead of square brackets. However, this results in unacceptably long serifs. I need a new command for something intermediate and very limited in use. I don't intend to use it for matrices or any other multi-line environment. Just one short text string between brackets. Unable to find a suitable ready-made solution, I decided to write such a command myself. After all, it's just one vertical bar and two horizontal serifs. This is what I got so far. \documentclass[12pt,a4paper,notitlepage]{report} \usepackage[cp1251]{inputenc} \usepackage[T1,T2A]{fontenc} \usepackage[russian]{babel} \usepackage{amsmath, amssymb} \usepackage{mathrsfs} \usepackage{enumitem} \usepackage{relsize} \usepackage{exscale} \usepackage{perpage} \usepackage{nicefrac} \usepackage[all,cmtip]{xy} \MakePerPage{footnote} \newcommand{\LBR}{ \hspace{0.2em}\rule[0.75em]{0.2em}{0.05em}% top serif \hspace{-0.2em}\rule[-0.2em]{0.2em}{0.05em}% bottom serif \hspace{-0.3em}\rule[-0.2em]{0.1em}{1.0em}% vertical bar \hspace{0.2em} } \newcommand{\RBR}{ \hspace{0.1em}\rule[0.75em]{0.2em}{0.05em}% top serif \hspace{-0.2em}\rule[-0.2em]{0.2em}{0.05em}% bottom serif \rule[-0.2em]{0.1em}{1.0em}% vertical bar \hspace{0.2em} } \newcommand{\opni}[1] {{\RBR #1 \LBR}} \newcommand{\opcli}[1]{{\RBR #1 \RBR}} \newcommand{\clopi}[1]{{\LBR #1 \LBR}} \newcommand{\clsi}[1] {{\LBR #1 \RBR}} \begin{document} \[ \begin{array}{ll} \opni{a, b} &=\ \{x\in A: a < x < b\},\\ \opcli{a, b} &=\ \{x\in A: a < x\leqslant b\},\\ \clopi{a, b} &=\ \{x\in A: a\leqslant x < b\},\\ \clsi{a, b} &=\ \{x\in A: a\leqslant x\leqslant b\},\\ \opni{{\gets},a} &=\ \{x\in A: x < a\},\\ \opcli{{\gets},a} &=\ \{x\in A: x\leqslant a\},\\ \opni{a,{\to}} &=\ \{x\in A: a < x\},\\ \clopi{a,{\to}} &=\ \{x\in A: a\leqslant x\}. \end{array} \] $\mathbb{R}^\clsi{a,b}$ \end{document} Although not very pretty, this solution is more or less satisfactory - except for two problems. First, in some random cases the vertical bar and one of serifs are too thick. Second and more important, the brackets are not scaled inside superscript, for example, in an expression like $\mathbb{R}^\clsi{a,b}$. The reason for the first problem I don't understand. The reason for the second I understand, but have no idea what to do about it. Any help is appreciated.
- Modifying existing math kerns (aka cut-ins or staircase kerning) to OpenType math fontsby Apoorv Potnis on February 26, 2026 at 6:53 am
It seems that the code from this answer works when introducing new math kerns (aka cut-ins or staircase kerning), but does not seem to modify existing ones. \documentclass{article} \usepackage{luacode} %using luacode package to add comments to the Lua code % code adapted from Marcel Kruger's answer https://tex.stackexchange.com/a/760117/128462 \begin{luacode} local kerns = { ["NewCMMath-Book"] = { ["uni211D.bb"] = { topright = { { kern = -70 } } }, -- DOUBLE-STRUCK CAPITAL R (Stylistic Set = 3) ["u1D6F9"] = {bottomright = { { kern = -1000 } } }, -- MATHEMATICAL ITALIC CAPITAL PSI }, } local function addkerns(tfmdata) if tfmdata.mathparameters then local kerns = kerns[tfmdata.properties.fontname] local unicodes = tfmdata.resources.unicodes if kerns then local characters = tfmdata.characters for name, specification in pairs(kerns) do local character = characters[unicodes[name]] if character and not character.mathkerns then character.mathkerns = specification end end end end end fonts.handlers.otf.features.register { name = "mathkerns", description = "additional math kerns", initializers = { position = 1, base = addkerns, node = addkerns, } } \end{luacode} \usepackage{unicode-math} \setmathfont[ StylisticSet={3}, BoldFont = NewCMMath-Bold.otf, RawFeature=+mathkerns ]{NewCMMath-Book.otf} % code copied from here https://tex.stackexchange.com/a/82221/128462 \everymath=\expandafter{% \the\everymath% \Umathsubshiftdown\textstyle=1.5pt\Umathsubshiftdrop\textstyle=0.5pt} \everydisplay=\expandafter{% \the\everydisplay% \Umathsubshiftdown\displaystyle=1.5pt\Umathsubshiftdrop\displaystyle=0.5pt} \usepackage{lua-visual-debug} \lvdset{glyph={show=true}} \begin{document} \(\symit{\Psi}_{\symit{\Psi}}\symbb{R}^n\) \end{document} This is a problem because of the modifications I've made. The math kerns in New Computer Modern Math have been set with the SubscriptShiftDown value set as 247 (1000 units = 10 pt) originally. This causes the subscripts to be placed too low, as compared to the traditional Computer Modern fonts. In order to change that, I've modified this parameter to 1.5pt, using Khaled Hosny's code. I found the 1.5pt value in the newcomputermodern-math.lfg goodie file for NewCM Math provided by ConTeXt (see lines 79 and 80). I wish to increase the math kern values for some glyphs. I've included \symbb{R}^n to show that the newly added math kern works, but does not modify the existing one (set to -1000 which should cause collisions). Answers to other engines are also welcome.
- I am plotting a family of parabolas in TikZ, and there is a stray parabola. I'm confusedby Jasper on February 25, 2026 at 7:14 pm
I am plotting a family of parabolas in TikZ, and there is a stray parabola. I'm confused. \documentclass[tikz,border=1cm]{standalone} \begin{document} \begin{tikzpicture} \pgfmathsetmacro{\SIGMALstart}{-3} \pgfmathsetmacro{\SIGMALstop}{3} \pgfmathsetmacro{\SIGMALsamples}{50} \pgfmathsetmacro{\SIGMALstep}{(\SIGMALstop-\SIGMALstart)/(\SIGMALsamples-1)} \foreach \SIGMAL[parse=true] in {\SIGMALstart,\SIGMALstart+\SIGMALstep,...,\SIGMALstop} { \draw[ variable=\TAUL, domain=-3:3 ] plot ( {\SIGMAL*\TAUL}, {((\TAUL)^2-(\SIGMAL)^2)/2} ); } \end{tikzpicture} \end{document}
- \nopagebreak in \paragraph don’t have effectby fauve on February 25, 2026 at 4:44 am
General overview I redefine \paragraph{} in order to get a wrap paragraph title like this : The problem But sometimes, when I reach the bottom page, a \section or \subsection comming just before the \paragraph stay at widow, like this: The MWE \documentclass{article} \usepackage{fontspec} \usepackage{xunicode} \usepackage{fontenc} \usepackage{wrapfig} \usepackage{needspace} \setlength\intextsep{0pt} \newlength{\wrapparwidth} \renewcommand{\paragraph}[1]{% %\needspace{3\baselineskip}% \nopagebreak[4]% \settowidth{\wrapparwidth}{\centering\bfseries\normalsize\small #1}% \ifdim\wrapparwidth>3cm% \setlength{\wrapparwidth}{3cm}% \fi% \begin{wrapfigure}{l}{\wrapparwidth} % l = left, 3cm largeur max \vspace{-0.04em} \centering\bfseries\normalsize\small #1 \end{wrapfigure}% \nopagebreak[4]% } \begin{document} Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \subsection{A random section} \paragraph{A random paragraph} Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \end{document} The question As you see, I used many \nopagebreak and also needspace to avoid this behaviour, but LaTeX wan’t hear my \nopagebreaks. So how do I avoid pagebreak between sectioning commands and the new defined \paragraph ?
- Spacing and dot weight in bsmallmatrix (from mathtools)by Dimitrios ANAGNOSTOU on February 24, 2026 at 4:45 pm
MWE \documentclass{article} \usepackage{mathtools} \begin{document} Le signe $(-1)^{i+j}$ suit un motif en damier : \( \begin{bsmallmatrix} + & - & + & - & \cdots \\ - & + & - & + & \cdots \\ + & - & + & - & \cdots \\ - & + & - & + & \cdots \\ \vdots & \vdots & \vdots & \vdots & \ddots \end{bsmallmatrix} \) \end{document} Questions There appears to be some horizontal empty space around the matrix. How can I remove or reduce it? It seems that \cdots is not as bold as \vdots and \ddots. Is this actually the case? If so, is there a way to make the various dots visually consistent? THANKS A LOT!
- What is the best way to draw a potato (like found in vector analysis/continuum mechanics courses)by Dimitrios ANAGNOSTOU on February 21, 2026 at 11:34 pm
I apologized if this is a duplicate. What is the best way to draw such figures with tikz (or other packages)? For the time being just the potato like figure. I do not care for the vectors and the infinitesimal mass element. I do not want someone to do the work for me. Just some advice or suggestions.
- Generate random, unique, nonzero integersby pwesterbaan on February 17, 2026 at 8:14 pm
I've been writing some commands that I use to randomize writing exam questions. I currently have the following code for generating "variables" containing (possibly non-zero) random integers: \newcommand{\randIntLower}{1} %Lower bound on rand ints \newcommand{\randIntUpper}{5} %Upper bound on rand ints \newcommand{\randIntTemp}{} %Used for defining values in randInts \newcommand{\randInts}[2][]{% % #1 = option (default: []; Use nz for nonzero) % #2 = list of variables % Uses \randIntLower and \randIntUpper as bounds (change with renewcommand if needed) \foreach \var in {#2}{% \ifstrequal{#1}{nz}{% % nonzero method: produces +/- nonzero random integers \pgfmathparse{int(ifthenelse(rand > 0, 1, -1)*random(\randIntLower,\randIntUpper))}% \expandafter\xdef\var{\pgfmathresult}% }{% \pgfmathrandominteger{\randIntTemp}{\randIntLower}{\randIntUpper}% \expandafter\xdef\var{\randIntTemp}% }% }% } This gives me something like this: \randInts[nz]{\randOne,\randTwo,\randThree} %\randOne -> 4 %\randTwo -> -2 %\randThree -> 4 This code works well enough, with the exception that I might get repeat random numbers. I've also been running into some of the limitations of pgfmath, so I'm now trying to rewrite the above using LaTeX3 syntax (hopefully fewer issues with calculations, and optional arguments aren't as positional). My hope is to have something that behaves as such: \randInts[nz]<1>(5){randOne, randTwo, randThree} %\randOne -> 4 %\randTwo -> -2 %\randThree -> 4 \randInts*[nz]<1>(5){randOne, randTwo, randThree} %\randOne -> 4 %\randTwo -> -2 %\randThree -> 6 It grieves me to say this, but I've been trying to write this with the help of Github's CoPilot. I have been reading whatever Latex3 documentation I could find (e.g. xparse, expl3, l3kernel), but for now, this is what I've got: \ExplSyntaxOn% % Flag: whether to generate ±nonzero \bool_new:N \l__randints_nonzero_bool % Parsed bounds \int_new:N \l__randints_min_int \int_new:N \l__randints_max_int \bool_new:N \l__randints_unique_bool \clist_new:N \l__randints_used_clist \int_new:N \l__randints_range_len_int \int_new:N \l__randints_slots_int % \randInts[nz?]<min>(max){name1,name2,...} % - [nz] or [nonzero]: produce ±(magnitude), where magnitude in [min,max] % - <min> and (max) are *separate* optional delimited args; defaults are 1 and 5 % - names are bare (no leading \); defines \name globally to the drawn integer \cs_new_protected:Npn \__randints_pick_unique:nn #1 #2 { \int_set:Nn \l_tmpa_int { \int_rand:nn { #1 } { #2 } } \prg_do_while:nn { \clist_if_in:NnTF \l__randints_used_clist { \int_to_arabic:n { \l_tmpa_int } } { \prg_return_true: }{ \prg_return_false: } } { \int_set:Nn \l_tmpa_int { \int_rand:nn { #1 } { #2 } } } } \cs_new_protected:Npn \__randints_pick_unique_signed:nn #1 #2 { % Loop until we find a nonzero signed value not yet used \int_zero:N \l_tmpa_int \prg_do_while:nn { % pick magnitude \int_set:Nn \l_tmpb_int { \int_rand:nn { #1 } { #2 } } % reject zero magnitude \int_compare:nNnTF { \l_tmpb_int } = { 0 } { \prg_return_true: } { % pick sign and form signed value \int_set:Nn \l_tmpc_int { \int_rand:nn { 0 } { 1 } } \int_set:Nn \l_tmpc_int { \int_eval:n { ( \l_tmpc_int * 2 - 1 ) * \l_tmpb_int } } \clist_if_in:NnTF \l__randints_used_clist { \int_to_arabic:n { \l_tmpc_int } } { \prg_return_true: } { \int_set:Nn \l_tmpa_int { \l_tmpc_int } \prg_return_false: } } } { } } \NewDocumentCommand \randInts { s o D<>{\randIntLower} D(){\randIntUpper} m } { % Determine nonzero mode from [ #2 ] \bool_set_false:N \l__randints_nonzero_bool \IfNoValueF{#2}{ \tl_if_eq:nnT {#2} {nz} { \bool_set_true:N \l__randints_nonzero_bool } } % starred variant -> unique values (no repeats): #1 is boolean from `s` \IfBooleanTF{#1} { \bool_set_true:N \l__randints_unique_bool } { \bool_set_false:N \l__randints_unique_bool } % Normalize order (so <7>(3) becomes [3,7]) \int_set:Nn \l_tmpa_int { \int_min:nn { \l__randints_min_int } { \l__randints_max_int } } \int_set:Nn \l_tmpb_int { \int_max:nn { \l__randints_min_int } { \l__randints_max_int } } \int_set_eq:NN \l__randints_min_int \l_tmpa_int \int_set_eq:NN \l__randints_max_int \l_tmpb_int % If unique requested, check availability and clear used list \int_set:Nn \l__randints_range_len_int { \int_eval:n { \l__randints_max_int - \l__randints_min_int + 1 } } % compute available slots for uniqueness \int_set:Nn \l__randints_slots_int { \l__randints_range_len_int } \bool_if:NTF \l__randints_unique_bool { \bool_if:NTF \l__randints_nonzero_bool { \int_set:Nn \l__randints_slots_int { \int_eval:n { 2 * \l__randints_range_len_int } } \int_compare:nNnT { \l__randints_min_int } <= { 0 } { \int_compare:nNnT { \l__randints_max_int } >= { 0 } { \int_set:Nn \l__randints_slots_int { \int_eval:n { \l__randints_slots_int - 2 } } } } } { \int_set:Nn \l__randints_slots_int { \l__randints_range_len_int } } \int_compare:nNnTF { \clist_count:n {#5} } > { \l__randints_slots_int } { \PackageError{exam}{Not~enough~unique~integers}{Requested~more~unique~integers~than~available~in~range.} } { \clist_clear:N \l__randints_used_clist } } { \clist_clear:N \l__randints_used_clist } % Generate for each bare name and define \name globally \clist_map_inline:nn { #5 } { \bool_if:NTF \l__randints_nonzero_bool { % \pm nonzero: sign * magnitude (support unique/starred) \bool_if:NTF \l__randints_unique_bool { \__randints_pick_unique_signed:nn { \l__randints_min_int } { \l__randints_max_int } \cs_gset:cpn { ##1 } { \int_to_arabic:n { \l_tmpa_int } } \tl_set:Nx \l_tmpa_tl { \int_to_arabic:n { \l_tmpa_int } } \clist_put_right:Nn \l__randints_used_clist { \l_tmpa_tl } } { \cs_gset:cpn { ##1 } { \int_eval:n { ( \int_rand:nn {0}{1} * 2 - 1 ) * \int_rand:nn { \l__randints_min_int } { \l__randints_max_int } } } } } { % Plain integer in [min,max] or unique selection if starred \bool_if:NTF \l__randints_unique_bool { % pick a unique random value via recursion \__randints_pick_unique:nn { \l__randints_min_int } { \l__randints_max_int } \cs_gset:cpn { ##1 } { \int_to_arabic:n { \l_tmpa_int } } \tl_set:Nx \l_tmpa_tl { \int_to_arabic:n { \l_tmpa_int } } \clist_put_right:Nn \l__randints_used_clist { \l_tmpa_tl } } { \cs_gset:cpn { ##1 } { \int_rand:nn { \l__randints_min_int } { \l__randints_max_int } } } } } } \ExplSyntaxOff% The issues I'm running into are that prg_do_while does not actually exist. The other recommendation that Co-Pilot had was to do a recursive call, but this seems like a worse idea. So, my questions are: What is the syntax for the while loop? How should I write this code? Am I over-complicating this whole problem? EDIT Based on @David Carlisle's and @egreg's suggestions, I came up with the following code: \ExplSyntaxOn \NewDocumentCommand \newrandInts { s o D<>{\randIntLower} D(){\randIntUpper} m O{1} }{ % \randInts[nz?]<min>(max){name1,name2,...}[t] % - [nz]: produce pm(magnitude), where magnitude in [min,max] % - <min> and (max) are *separate* optional delimited args; defaults are 1 and 5 % - clist of names; defines \name globally to the drawn integer % - optional randInt multiplier t (defaults to 1) \tl_clear_new:N \l__my_number_tl \seq_clear_new:N \l_numbers_seq \tl_if_eq:nnT {#2} {nz}{ \int_step_inline:nnn {-#4}{-#3} { \seq_put_right:Nn \l_numbers_seq { \fp_eval:n{ ##1 * #6 } } } } \int_step_inline:nnn {#3}{#4} { \seq_put_right:Nn \l_numbers_seq { \fp_eval:n{ ##1 * #6 } } } \seq_shuffle:N \l_numbers_seq \clist_map_inline:nn { #5 } { \IfBooleanTF{#1}{ \seq_pop_left:NN \l_numbers_seq \l__my_number_tl \cs_gset:cpx { ##1 } { \tl_use:N \l__my_number_tl } }{ \cs_gset:cpx { ## 1 } { \seq_rand_item:N \l_numbers_seq } } } } \ExplSyntaxOff I use the code like this: \newrandInts*[nz]{a,b,c,d}[3] \a, \b, \c, \d % prints nonzero random integers between -5 and 5 % multiplied by 3 without repeats: % -3, -9, 3, -6 \newrandInts{a,b,c,d}[0.1] \a, \b, \c, \d % prints random integers between 1 and 5 % multiplied by 0.1 with repeats possible: % 0.3, 0.5, 0.4, 0.1 The multiplication by a scalar was a bit of an afterthought because my current workflow is define random integers, then scale them up.
- Introducing a vertical line in a quantikz circuitby Rob on February 17, 2026 at 10:44 am
I have the following circuit generated using quantikz: \documentclass{article} \usepackage{quantikz} \begin{document} \begin{center} \begin{quantikz}[row sep=.2cm, column sep=.5cm] \lstick{$|0\rangle$} & \gate{A} & \gate[2]{B} & \ghost{C} & \gate{D} & \\ \lstick{$|1\rangle$} & & & \gate[2]{C} & \gate{E} & \\ \lstick{$|1\rangle$} & & & & \gate{F} & \end{quantikz} \end{center} \end{document} How can I introduce some vertical lines as shown in the attached screenshot below
- \mathunderbar automatically gobbles the subscript following itby Jinwen on February 16, 2026 at 3:27 am
Consider the following example: \documentclass{article} \usepackage{unicode-math} \begin{document} \( \mathunderbar{s}_f \) \( \mathunderbar{s}{}_f \) \end{document} It seems \mathunderbar automatically interprets the subscript following it as part of its argument. Is this behavior by design? Should I thus always write an empty group after it to get the correct output, as in the example above?
- TeX expansion with \number has mysterious error when followed by space, why?by Dan Levin on February 15, 2026 at 3:07 pm
This code produces the table I'm expecting with fully expandable copying: % same as \ltx@\ReturnAfterFi \long\def\ReturnAfterFi#1\fi{\fi#1} % expandable copies % #1=number, #2=text \def\xcopies#1#2{% \ifnum#1>0 #2% \ReturnAfterFi{\expandafter\xcopies\expandafter{\the\numexpr#1-1}{#2}}% \fi} \def\hundredtable{% \vtop{\offinterlineskip \global\count255=1 \everycr{\noalign{\hrule}}\tabskip0pt \halign{\strut \vrule ##&& \global\advance\count255 by 1 \hbox to 2.5em{\hss##\hss}\vrule\cr \xcopies{10}{\xcopies{10}{& \number\count255}\cr}\crcr}}} \hundredtable But an error occurs if I put a space after the \number command in the code block above, as shown here: ... \xcopies{10}{\xcopies{10}{& \number\count255 }\cr}\crcr}}} I thought the space would be optional. I've tried \relax and it, too, produces an error, with TeX saying the \ifnum doesn't complete. I suspect the \number command with the register is checking if it should multiply what follows and is therefore expanding the \ReturnAfterFi. But the space would seem to solve this, not cause it. Can someone explain the expansion error here?
- Strange geometric calculation error of ellipse with `arc` in tikz?by Explorer on February 14, 2026 at 7:33 am
I want to plot something as below in an elegant appraoch, with a handy control of the angle and eccentricity: (the pattern is not important here) Here below, I make some calculations: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture}[line join=round] \def\R{5} \def\ell{0.9} \def\startAngle{40} \def\endAngle{90-\startAngle} \def\rhoo{\fpeval{\R*sind(45-\startAngle)/cosd(\startAngle)}} \def\Rx{\fpeval{\rhoo*(sqrt(1-(\ell^2*cosd(\startAngle)^2)))/(sqrt(1-\ell^2))}} \def\Ry{\fpeval{\Rx*(sqrt(1-\ell^2))}} \def\ellstartAngle{\fpeval{atand(\Rx/\Ry*tand(\startAngle))}} \filldraw[ fill=cyan!30, draw=cyan, very thick ] (\R,0) arc[start angle=0, end angle=\startAngle, radius=\R] { [rotate=-\startAngle] arc[start angle=-\ellstartAngle,end angle=180+\ellstartAngle,x radius=\Rx,y radius=\Ry] } arc[start angle=\endAngle, end angle=90, radius=\R] -- (0,\R) -- (\R,\R) -- cycle; \end{tikzpicture} \end{document} But it gives some drawbacks of the ellipse's ending tip: With the following sketch: My calculation thoughts is as below: noted that \StartAngle is \theta, and \ell is the ellipse's eccentricity with \def\rhoo{\fpeval{\R*sind(45-\startAngle)/cosd(\startAngle)}}, I want to derive the radius from origin of the ellipse, that is the \rho's distance in the sketch with the formula of the radius length from origin of the ellipse, that is: I want to derive the x-radius of ellipse, that is a(\Rx) via \def\Rx{\fpeval{\rhoo*(sqrt(1-(\ell^2*cosd(\startAngle)^2)))/(sqrt(1-\ell^2))}} Then I calaulated the y-radius with \Rx and \ell via \def\Ry{\fpeval{\Rx*(sqrt(1-\ell^2))}} Finally, I calculate the geometric angle of sub-path rotation learning from this answer via \def\ellstartAngle{\fpeval{atand(\Rx/\Ry*tand(\startAngle))}} I really have no idea of any mathematical calculation issues or just my tikz's parameter misunderstandings. Could somebosy give me a hand? (Any approach with neat syntax are all welcome! My calculation above is just to draw this in one \path)
- tabularx: more horizontal distance between {|X| |X|}by cis on February 14, 2026 at 7:05 am
How do I get more horizontal distance ? \documentclass[paper=a5]{scrarticle} \usepackage[margin=14mm, showframe=true]{geometry} \usepackage{tabularx,hhline,booktabs} \begin{document} \setlength{\arrayrulewidth}{3pt}% to see the rules clearly %\setlength{\tabcolsep}{5mm}% ungood \noindent% \begin{tabularx}{\textwidth}{|X| |X|} \hhline{|-||-|} Content Column 1 & Content Column 2 \\ \hhline{|-||-|} \end{tabularx} \end{document}
- Bold math with unicode-math and siunitxby pejsek on February 12, 2026 at 5:42 pm
I am creating a table that needs a bold header. In the header I want to typeset units using siunitx. I want the units to be inside parentheses. I am also using the unicode-math package and compiling with LuaLaTeX. \documentclass{article} \usepackage{fontspec} \usepackage{unicode-math} \usepackage{booktabs} \usepackage{siunitx} \begin{document} \centering \setlength{\tabcolsep}{5mm} \renewcommand{\arraystretch}{1.1} \begin{tabular}{@{} l c @{}} \toprule \textbf{Material} & \textbf{Density} \(\symbf{ \left( \unit[per-mode=fraction]{\gram\per\centi\metre\cubed} \right) }\) \\ \midrule Air & \num{0.0012} \\ Water & \num{1} \\ \bottomrule \end{tabular} \end{document} The output looks like this: I want all of the header to be bold, including the scalable parentheses and all of the units. Like this: \documentclass{article} \usepackage{fontspec} %\usepackage{unicode-math} \usepackage{booktabs} \usepackage{siunitx} \begin{document} \centering \setlength{\tabcolsep}{5mm} \renewcommand{\arraystretch}{1.1} \begin{tabular}{@{} l c @{}} \toprule \textbf{Material} & \textbf{Density} \boldmath\( \left( \unit[reset-math-version=false,per-mode=fraction]{\gram\per\centi\metre\cubed} \right) \) \\ \midrule Air & \num{0.0012} \\ Water & \num{1} \\ \bottomrule \end{tabular} \end{document} I experimented with some variations of this question but without much success. Thank you for any help.
- Crop certain percent from each side of the figureby monty01 on February 11, 2026 at 8:20 pm
I would like to crop x percent from each side from the img. \documentclass{article} \usepackage{graphicx} \begin{document} \begin{figure}[h] \centering \includegraphics[scale=0.3]{example-image-a} \caption{Caption} \label{fig:placeholder} \end{figure} \end{document} insted of using \includegraphics[scale=0.3]{example-image} I would like to call \cropimg{scale}{img}{crop percentage}
- How can the roots of a quadratic equation be written in radical form?by Laurenso on February 10, 2026 at 3:52 am
I am trying to express the roots of a quadratic equation `t^2-3t-7=0' in radical form. I tried \documentclass[12pt]{article} \usepackage{polexpr} \usepackage{xint} \begin{document} \poldef f(t) = t^2-3t-7; \xintdefvar a = (f(2)-2*f(1)+f(0))/2; \xintdefvar c = f(0); \xintdefvar b = reduce(f(1)-a-c); \xintdefvar delta = b^2 - 4*a*c; \xintdefvar t1=reduce((-b+sqrt(delta))/2/a); \xintdefvar t2=reduce((-b-sqrt(delta))/2/a); \[\xinteval{t1}, \quad \xinteval{t2}\] \[t=\frac{1}{2} \left(3-\sqrt{37}\right)\lor t=\frac{1}{2} \left(3+\sqrt{37}\right).\] \end{document} I got How can I get?
- Twisted Equalityby Entropy on February 8, 2026 at 8:14 pm
I am trying to create a new math symbol. Could someone please help me with it? My current code: \documentclass[12pt]{report} \RequirePackage{tikz} \newcommand{\eq}{\begin{tikzpicture}% [scale=.175, line width=0.5pt] \draw (-1,1) -- (0,0); \draw (0,1) -- (-0.5,0.5); \draw (0,-1) -- (-1,0); \draw (-0.5,-0.5) -- (-1,-1); \end{tikzpicture}} \begin{document} \[ u - \eq - u \] \end{document} However, the symbol I am actually going for is this: I was using it for something like this:
- Unequal parens sizes in numerator and denominator of a fractionby Knudsen on February 6, 2026 at 2:22 pm
Why are the parens on the numerator of this construction much bigger than the ones in the denominator? \documentclass{report} \usepackage{amsmath} \begin{document} \[ \frac{\left(q^k\right)} {\left(q^k\right)} \] \end{document}
- Make perfect circular diagramsby Fran on February 5, 2026 at 12:23 pm
I know that I can make circular diagrams with the nice smartdiagram package, but arrows do not fit perfectly in a imaginary circle. In fact, the diagram is far from a circle when there are only two or three nodes: \documentclass{standalone} \usepackage{smartdiagram} \begin{document} \smartdiagramset{ connection color=red, module shape= circle, circular distance=2cm, uniform color list=white for 6 items, uniform arrow color=true, arrow color=black} \smartdiagram[circular diagram:clockwise]{foo, bar} \end{document} I know also that there are several examples in this site about making circular diagrams without this package, but translating these examples to diagrams with a different numbers of nodes is complex, so I tried an automated solution with tikz (without really knowing what I was doing, I have to admit) so that I only have to modify a list of nodes in \mylist and little more to obtain the result: \documentclass[border=2mm]{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}[ > = Stealth, every node/.style = {circle, draw, thick, minimum width=1cm, align=center} ] \def\mylist{foo, bar, baz} % play with this \foreach \x [count=\i from 1] in \mylist {\xdef\n{\i}} \def\radio{2cm} % and this if needed \foreach \texto [count=\i from 0] in \mylist{ \pgfmathsetmacro\ang{-\i*360/\n} \node (n\i) at (\ang:\radio) {\texto}; } \foreach \dummy [count=\i from 0] in \mylist{ \pgfmathsetmacro\j{int(mod(\i+1,\n))} \pgfmathsetmacro\angini{-\i*360/\n} \pgfmathsetmacro\angfin{-\j*360/\n} \pgfmathsetmacro\outang{mod(\angini - 90 + 720, 360)} \pgfmathsetmacro\inang {mod(\angfin + 90 + 720, 360)} \draw[->, thick, line width=1.4pt] (n\i) to[out=\outang, in=\inang, looseness=.9] (n\j); % and with the looseness } \end{tikzpicture} \end{document} Mainly it works. The problem is that like in smartdiagram, the arrows don't perfectly follow an imaginary circle, that was the idea behind getting involved in this business. Playing with looseness is possible to correct a bit the curvature of the arrows, but it's tedious and the result is never perfect. So, the result should be ideally near to the image below (that I modified manually in Inkscape) and still require minimal settings to adapt the code to diagrams of n nodes. Fixes of the MWE as well as alternative approaches are welcome. Edit Thank you all for the excellent suggestions. This time, I am truly sorry I can only accept one.
- How to add fermata symbol to metre package?by rensemil on February 3, 2026 at 11:10 am
I am using the package metre. It has the environment \metra{} used for typesetting latin (and greek) metre notation. This environment has almost all the special characters I need, except one: I need a character that looks somewhat like a fermata 𝄐 but preferrably in the same style as the other metrical symbols. This could, I believe, be achieved by simply taking the character breve that is produced by \documentclass{article} \usepackage[en]{metre} \begin{document} \metra{\a\m\b\bm} \end{document} and have it flipped upside down and a dot put underneath. In a book, this is what it looks like: It's the last symbol of each of the lines in the box. Does anyone know how this could be achieved? I even tried contacting the package's creator but his email address does not seem to exist anymore. My MWE produces the symbols in this picture (the ones inside the brackets): After implementing the answer by samcarter_is_at_topanswers.xyz, the symbol now looks perfectly, but there is suddendly too much space to the right of it: This is produced by \metra{\b\m\fer\b\m\fer\m\b} with \newcommand{\fer}{\kern0.15em\raisebox{0.07em}{\rotatebox{180}{\rlap{\kern0.3em\raisebox{0.07em}{\scalebox{0.5}{.}}}\b}}} I am using \Magnitudo{+1} \InterSigna{.6} as options for the package The space to the right should be identical to the space on the left. Can this be fixed? Thanks in advance!