Week
- Matrix with NiceMatrixby Knudsen on December 15, 2025 at 5:01 am
I am trying to produce a (n+1)x(n+1) matrix with diagonal elements equal to 1 supradiagonal (one above the diagonal) a sequence from 1 to n everything else 0 in the package NiceMatrix, and with the code (processed twice): \documentclass{report} \usepackage{nicematrix} \begin{document} \[ \begin{pNiceMatrix}[renew-dots] 1 & 1 & 0 & \Cdots & 0 \\ 0 & 1 & \ddots & \ddots & \Vdots\\ \Vdots & \ddots & \ddots & & 0 \\ & & & 1 & n \\ 0 & \Cdots & & 0 & 1 \end{pNiceMatrix} \] \end{document} I get a strange shortening of the vertical separation of the two last rows, which is considerably smaller than the separation of the first two, producing an artifact at the meeting of the two dotted lines at the last zero on the matrix. What could be causing this? I do know that I can add [0.22cm] to the line before last and add some space, but that seems a bit weird.
- Evolution of “Computer Modern” or who lowered the dot on the “i”?by Alain Stalder on December 14, 2025 at 12:27 pm
In the process of hopefully migrating some documents from pdflatex that use Computer Modern fonts (mostly Sans) to LuaLaTeX, I am looking at the different variants that have evolved since the original METAFONT Computer Modern family. The good news for me is that the differences seem to be smaller than it first appeared, both regarding glyphs and metrics. The most prominent difference in Latin Modern with “plain English characters” is that the dot on the lowercase letter “i” is a bit lower, at least in the Sans variants (except in ligatures like “fi” where the height of the dot matches the too of the “f”). Was that a conscious choice in Latin Modern? Or maybe already in an earlier variant which I could not find, yet? (Computer Modern Unicode and CM-Super seem to have the original height of the dot on the “i”.) CTAN does list various Computer Modern variants and there is also some info in its external references, but I was wondering if there is maybe additional historical info about the evolution of “Computer Modern” variants, maybe a TUGboat article about that or maybe that someone who was already somewhat involved at the time would still remember? Below some examples with sources and — to make sure — the font that was actually used from the console log, and some differences noticed in the example text. pdflatex / Computer Modern (the reference; same result with \usepackage{amsfonts}, as expected): % !TEX TS-program = pdflatex \documentclass{article} \renewcommand\familydefault{\sfdefault} \begin{document} Liegenstraße 95 in “larger” Wil… % </usr/local/texlive/2025/texmf-dist/fonts/type1/public/amsfonts/cm/cmss10.pfb> \end{document} pdflatex / CM-Super: % !TEX TS-program = pdflatex \documentclass{article} \usepackage[T1]{fontenc} \renewcommand\familydefault{\sfdefault} \begin{document} Liegenstraße 95 in “larger” Wil… % </usr/local/texlive/2025/texmf-dist/fonts/type1/public/cm-super/sfss1000.pfb> \end{document} (Different “ß” and different spacing before “, rest same incl. “i”.) LuaLaTeX / Computer Modern Unicode: % !TEX TS-program = lualatex \documentclass{article} \usepackage{fontspec} \setmainfont{CMU Sans Serif} \begin{document} Liegenstraße 95 in “larger” Wil… % </usr/local/texlive/2025/texmf-dist/fonts/opentype/public/cm-unicode/cmunss.otf> \end{document} (Same alternative “ß” as CM-Super, different space after ”, denser ellipsis, rest same incl. “i”) LuaLaTeX / AMS Type 1 converted to OpenType (using FontLab 8 on Mac): % !TEX TS-program = lualatex \documentclass{article} \usepackage{fontspec} \setmainfont{ams-cmss10.ttf} \begin{document} % emulated ellipsis… Liegenstraße 95 in “larger” Wil.\,.\,. % <./ams-cmss10.ttf> \end{document} (Almost identical to Computer Modern (as expected), except line overall a bit denser and had to emulate the ellipsis, same “i”.) LuaLaTeX / Latin Modern: % !TEX TS-program = lualatex \documentclass{article} \renewcommand\familydefault{\sfdefault} \begin{document} Liegenstraße 95 in “larger” Wil… % </usr/local/texlive/2025/texmf-dist/fonts/opentype/public/lm/lmsans10-regular.otf> \end{document} Here the dot on the “i” is a bit lower. Also, the “a” has the same metric but is shifted a bit to the right. Also, more space inside “...”, and also denser ellipsis. Diff between LM and AMS OpenType (would be practically the same to pdflatex / Computer Modern, but wanted to stick to OpenType, into the future): The dot on the “i” is lowered and the “a” is shifted, otherwise letters just shifted a tiny little bit, but maybe that would be just a rendering artefact/limitation, at some point becomes the princess and the pea… But overall, seems like an “AMS to OpenType x Latin Modern” (as new font or maybe a virtual font on-the-fly) could already come close to the original pdflatex / Computer Modern look and feel for texts that could already be typset with the limitations regarding language support of pdflatex / Computer Modern. Added same day: Here’s a diff between LuaLaTeX / Latin Modern and pdflatex / Computer Modern, almost only the dot on the ”i” and the shift of the “a” are different, the other letters shifted in the diff above was just that was more condensed with LuaLaTeX / ”AMS OpenType” as I had mentioned but forgot about again. Added 2025-12-16: Examples with “New Computer Modern” also in the heavier book style. Note that, at least so far, I can only see 8pt and 10pt versions of that font in TeXLive 2025, i.e. at different sizes results would differ more from Computer Modern (and also from Latin Modern, for example), which would so far be a no-go for me because I have lots of 9pt stuff in my documents. Also, slanted text seems to be very heavily slanted. LuaLaTex / New Computer Modern: % !TEX TS-program = lualatex \documentclass{article} \usepackage[sansdefault]{fontsetup} \begin{document} Liegenstraße 95 in “larger” Wil… % </usr/local/texlive/2025/texmf-dist/fonts/opentype/public/newcomputermodern/NewCMSans10-Regular.otf> \end{document} (Output identical to Latin Modern, except that the upper horizontal line of the uppercase letter “L” is completely horizontal; I guess the choice in Computer Modern and Latin Modern for 10pt might have been to make it look horizontal at 10pt and maybe with New Conmputer Modern, since that is also the largest size font, it was made horizontal to look horizontal at larger point sizes?) LuaLaTex / New Computer Modern Book: % !TEX TS-program = lualatex \documentclass{article} \usepackage[default]{fontsetup} \renewcommand\familydefault{\sfdefault} \begin{document} Liegenstraße 95 in “larger” Wil… % </usr/local/texlive/2025/texmf-dist/fonts/opentype/public/newcomputermodern/NewCMSans10-Book.otf> \end{document} (As expected a bit heavier (with a nice amount to me), but otherwise the same.)
- How to draw a parabola in Ipe?by Dominik Mokriš on December 14, 2025 at 12:13 pm
Note: This question has been closed as off-topic on stackoverflow.com. I believe it's on-topic here under the [ipe] Tag. How can you draw a parabola in ipe? Usually, I use "Splines [I]" but it's not exactly convenient, as I need to construct four control points so that they correspond to a degree-elevated Bézier curve. Recently, I noticed the option "Ipelets > Goodies > Make parabolas". However, I am failing to guess the correct inputs. Here's what I tried: Make a line segment using "Lines and polylines [P]." Create a point using "Marks [M]." Select the line, press "Shift" and select the point. Go to "Ipelets > Goodies > Make parabolas." This fails with the following message. Neither in the manual, nor googling around have I found any further hints. Ideas?
- Why does \changefontsize from the fontsize package mess with \centering?by palapapa on December 14, 2025 at 5:44 am
MWE: \documentclass{article} \usepackage{anyfontsize} \usepackage[fontsize = 40]{fontsize} \begin{document} \centering \changefontsize{40} aaa \end{document} Notice how I am changing the font to the same size, yet the problem still happens. The large font size makes it easier to see that the line is off-center. Result: If I swap the order of \changefontsize and \centering or remove \changefontsize, the text will be correctly centered. Why is this?
- TikZ, \x^2 != \x * \x?by ana on December 13, 2025 at 8:04 pm
Why do the two \draw commands produce two different plots? Shouldn't they both produce a parabola? How do you use the ^2 notation to plot a parabola? \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[domain=-1:1] plot (\x, \x^2); \draw[domain=-1:1] plot (\x, \x * \x); \end{tikzpicture} \end{document}
- Graphing the function y=x^2sin(1/x)by azetina on December 13, 2025 at 6:50 pm
Consider the following MWE: \documentclass{article} \usepackage{amsmath} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ axis equal, axis lines = middle, xlabel = $x$, ylabel = $y$, xmin = -0.4, xmax = 0.4, ymin = -0.4, ymax = 0.4, grid = both, grid style = {line width=.1pt, draw=gray!10}, major grid style = {line width=.2pt, draw=gray!50}, samples = 200, legend pos = north west, width = 10cm, height = 8cm ] % Plot the curve \addplot[domain=-0.4:0.4, thick, blue] {x^2*sin(1/x)}; \addlegendentry{$y = x^2\sin(1/x)$} % Tangent line at (1, -2) \addplot[domain=-0.5:0.5, thick, red] {x^2}; \addplot[domain=-0.5:0.5, thick, red] {-x^2}; \addlegendentry{$y=\pm x^2$} \end{axis} \end{tikzpicture} \end{document} Currently, I am getting: But I would like the curve to show like in the following image: What am I missing?
- Strange spacing on a matrixby Knudsen on December 13, 2025 at 6:46 pm
Why would the vertical spacing between the 2nd and 3rd lines in this matrix be larger than the others? \documentclass{report} \usepackage{amsmath} \begin{document} \[ \begin{pmatrix} 1 & 0 & \cdots & 0 \\ 0 & 1 & \cdots & 0 \\ \vdots&\vdots&\ddots&\vdots\\ 0 & 0 & \cdots & 1 \end{pmatrix} \] \end{document}
- How can I mimic Griffiths' quantum mechanics textbook (3rd edition)?by Lucas Cesena on December 13, 2025 at 4:06 pm
I'm using LaTex to write my physics bachelor thesis and I want it to look similar to one of my favourite undergraduate textbooks on physics: Griffith's Introduction to Quantum Mechanics, specifically the third edition of 2018. I've successfully mimicked the example/proof boxes and also the problem boxes using the tcolorbox package, but didn't manage to find out how to do the same chapter/section display and what font is being used. If anyone can help me on this I'd be extremely grateful! Here is one example page:
- Additive color mixing in set diagramsby Alma Arjuna on December 13, 2025 at 3:19 pm
I've made a pretty set diagram! I'm not happy with how the colors are interacting on the set intersections, though. Because of the order the sets are built, each one is visibly 'above' or 'below' each other, breaking the symmetry of the figure. Of course, this behavior is expected. Can we make so that the colors interact additively instead? I know I can go intersection-by-intersection changing the colors to whatever I want, but this seems very inefficient and I wouldn't know how to manually combine the colors anyway... Here is the code. \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{calc} \tikzstyle{vertex}=[circle,fill=black,inner sep=2.2pt] \begin{document} \begin{tikzpicture}[scale=1] \coordinate (A) at (18:{sqrt(5)}); \coordinate (B) at (90:{sqrt(5)}); \coordinate (C) at (162:{sqrt(5)}); \coordinate (D) at (234:{sqrt(5)}); \coordinate (E) at (306:{sqrt(5)}); \def\set{ellipse (2.618cm and 0.382cm)} \fill[magenta, opacity=.36] ($(A)!0.5!(C)$) \set; \fill[cyan, opacity=.36, rotate=72] ($(B)!0.5!(D)$) \set; \fill[yellow, opacity=.36, rotate=144] ($(C)!0.5!(E)$) \set; \fill[violet, opacity=.36, rotate=216] ($(D)!0.5!(A)$) \set; \fill[green, opacity=.36, rotate=288] ($(E)!0.5!(B)$) \set; \node[vertex] at (A) {}; \node[vertex] at (B) {}; \node[vertex] at (C) {}; \node[vertex] at (D) {}; \node[vertex] at (E) {}; \coordinate[vertex] (F) at ($(A)!0.382!(C)$); \coordinate[vertex] (G) at ($(B)!0.382!(D)$); \coordinate[vertex] (H) at ($(C)!0.382!(E)$); \coordinate[vertex] (I) at ($(D)!0.382!(A)$); \coordinate[vertex] (J) at ($(E)!0.382!(B)$); \end{tikzpicture} \end{document}
- Using \par directly in enumitem's itemjoinby Erwann on December 13, 2025 at 3:10 am
I'm using enumitem to typeset paragraphs, whether contiguous or joined using \par. For this last case, itemjoin={\par} triggers an error, hence the shown workaround. Is there an inline solution (wild guess \exp_not:N did not work). *.tex \documentclass{article} \usepackage{enumitem} \usepackage{lipsum} \ExplSyntaxOn \cs_new:Npn \g__erw_par { \par } % workaround \newlist{my-list}{itemize*}{1} \setlist[my-list]{ label={}, % itemjoin={\par} itemjoin={\g__erw_par} % workaround } \ExplSyntaxOff \begin{document} \ExplSyntaxOn \begin{my-list}[after={\g__erw_par foo}] \item \lipsum[1][1] \item \lipsum[1][2] \end{my-list} \ExplSyntaxOff \lipsum[1][1-2] \end{document} Post Scriptum: the proposed workaround solves the compilation error but does not render as expected. The choice seems to between itemize or itemize*, but no crossover. terminal: Runaway argument? {label={},itemjoin={ ! Paragraph ended before \enit@setlist@i was complete. <to be read again> \par l.11 itemjoin={\par } ?
- Lettrine breaks wrapfigure and marginnoteby DanDucky on December 13, 2025 at 1:30 am
I'm trying to make a template which uses wrapfigure (for wrapped text), marginnote, and lettrine. I've gotten all of the first 2 to play nice together, but the problem has started at lettrine. Basically, when I use lettrine and marginnote together then wrapfigure breaks and stops placing its text in the correct place. If I remove the marginnote then wrapfigure works with lettrine. The marginnote itself remains unaffected when I use lettrine, it just breaks wrapfigure. I've tried recreating the lettrine effect with wrapfigure only but ran into similar issues. I've made a minimum reproduction of this below, thank you in advance. I'm using Tectonic. \documentclass{article} \usepackage[ letterpaper, % or letterpaper, etc. margin=3cm, footskip=1cm % space between bottom of text and baseline of footer ]{geometry} \usepackage{lettrine} \usepackage{wrapfig} \usepackage{marginnote} \usepackage{lipsum} \usepackage{marginnote} \newcommand{\colnote}[1]{% \marginnote{% \footnotesize% #1% }% \normalmarginpar% in my main code this is determined by a \whichcolumn } \newcommand{\wrappedtext}[1]{% % in my main code this is l/r depending on column \begin{wrapfigure}{l}{0.4\linewidth}% \textit{#1}% \end{wrapfigure}% } \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % when this is uncommented the whole thing breaks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\lettrine{L}{orem} \lipsum[1][1-8] \wrappedtext{\lipsum[1][1-2]} \lipsum[1][11-15] \colnote{\lipsum[1][3-4]} \lipsum[2-3] \end{document}
- Top align display style formula in table cellby lela2011 on December 12, 2025 at 10:46 pm
I am currently working on a cheat sheet. It is composed of a table with three columns. The first one is a keyword, the second one either a text explanation or a formula and the third one is a variable definition. The following is a minimal working example \documentclass[a4paper, twocolumn, landscape]{article} \usepackage[margin = 7mm, headsep=3mm, includehead]{geometry} \usepackage[fleqn]{amsmath} \usepackage{amsfonts, amssymb, mathtools} \usepackage{bm} \usepackage{siunitx} \usepackage{braket} \newcommand{\dd}{\mathrm{d}} \newcommand{\pd}{\partial} \DeclareMathOperator{\ham}{\hat{H}} \DeclareMathOperator{\mom}{\hat{p}} \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} \DeclarePairedDelimiter{\norm}{\lVert}{\rVert} \makeatletter \let\oldabs\abs \def\abs{\@ifstar{\oldabs}{\oldabs*}} % \let\oldnorm\norm \def\norm{\@ifstar{\oldnorm}{\oldnorm*}} \makeatother \usepackage{tabularx} \usepackage{booktabs} \usepackage{array} \usepackage{makecell} \newcommand{\mc}[1]{\makecell{#1}} \renewcommand{\cellalign}{tl} \newcolumntype{L}{>{\raggedright\arraybackslash}p{0.2\linewidth}} \newcolumntype{F}{>{\raggedright\arraybackslash \abovedisplayskip=0pt \belowdisplayskip=0pt \abovedisplayshortskip=0pt \belowdisplayshortskip=0pt \mathindent=0pt \partopsep=0pt \topsep=0pt}p{0.5\linewidth}} \newcolumntype{E}{>{\raggedright\arraybackslash}X} \newenvironment{formtab}[1][1.2] { \renewcommand{\arraystretch}{#1} \fontsize{8}{8}\selectfont \tabularx{\linewidth}{@{} L F E @{}} } { \endtabularx } \begin{document} \subsubsection{Wavefunction - Discrete} \begin{formtab} discrete basis & set of discrete states $\{ \Psi_n \}$ with $\braket{\Psi_n | \Psi_m} = \delta_{nm}$ & \\ arbitrary state & \[ \ket{\Psi} = \sum_{n=1}^\infty a_n \ket{\Psi_n}, \quad a_n = \braket{\Psi_n | \Psi} \] & \\ probability & $P_\Psi(n) = \abs{a_n}^2 = \abs{\braket{\Psi_n | \Psi}}^2$ & \\ normalization & $\braket{\Psi | \Psi} = 1$ \end{formtab} \end{document} The table now looks like this I want the display style formula to sit flush with the top of the cell though. I have tried using $\displaystyle a^2+b^2=c^2$. This causes the keyword to be centered with the formula. Using \vspace(-.5cm) works partially but that would require me to manually find the correction which is not sensible if the entire document is made up of formulas. Do you have any ideas how this could be achieved?
- How to draw a pattern within a path that features a visible decorated path and also invisible paths? OR How to visualize the ground?by Simon on December 12, 2025 at 6:13 pm
How does the following MWE need to be modified to only visualize the decorated path but not the remaining path and draw the top right-hand corner not rounded? \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{patterns} \begin{document} \begin{tikzpicture} \path[draw,pattern=north west lines] decorate[decoration={random steps,segment length=1,amplitude=.2},rounded corners=.2] {(-1,0) -- (0,0) -- (1,0)} -- (1,-.25) -- (-1,-.25) -- cycle; \end{tikzpicture} \end{document} Thanks in advance!
- LuaTeX (and other engines) equivalent of the \showglyphs command in ConTeXt for mathby Apoorv Potnis on December 12, 2025 at 3:07 pm
We can use the \showglyphs commannd in ConTeXt to show the bounding boxes of glyphs, both text and math. It also shows the baseline. \showglyphs \starttext Lorem ipsum \startformula \int_\Gamma f \cdot dx = 1 \stopformula \stoptext What are the equivalent commands with other engines, such as Lua(La)TeX, Xe(La)TeX, OpTeX, and even pdf(La)TeX if possible? The answers here don't work for math: Bounding box for each letter. The package lua-visual-debug does not seem to create boxes for all the glyphs involved in the equations.
- Reduce spacing in TikZ state diagram with split nodesby mingabua on December 12, 2025 at 11:55 am
I have the following code to create a tikzpicture of a labelling algorithm. However, I am currently not satisfied with the way it looks right now. Every looks to big and to much spread out. How can I create a more condense but still clear version of it. For (1); the vertical space between the boxes should be smaller. (2) the box height should be decreased and (3) the text inside the box should be more condense. The font size could be decreased as well. This is my code: \documentclass{article} \usepackage[margin=1in]{geometry} \usepackage{tikz} \usepackage{amsmath} \usetikzlibrary{positioning, arrows.meta, shapes.multipart, calc} \usepackage{lipsum} \begin{document} \lipsum[1] \begin{figure}[htbp] \centering \begin{tikzpicture}[ scale=1, % --- STYLES --- node distance=2.5cm and 3cm, font=\sffamily\footnotesize, % Label Box labelnode/.style={ rectangle split, rectangle split parts=2, draw=black!80, rounded corners, fill=gray!5, align=center, inner sep=3pt, minimum width=2.1cm }, % Infeasible (MS Pruning) - Rot infeasible/.style={ labelnode, draw=red!80, fill=red!5, dashed }, % Dominated (History Dominance) - Lila dominated/.style={ labelnode, draw=violet!80, fill=violet!5, dashed }, % Optimal Path Node - Grün optimal/.style={ labelnode, draw=green!50!black, fill=green!10, line width=1pt }, % Edges worker/.style={-{Latex[length=3mm]}, blue!70!black, thick}, ai/.style={-{Latex[length=3mm]}, orange!80!black, thick}, optedge/.style={worker, line width=1.5pt, green!40!black}, prunededge/.style={-{Latex[length=3mm]}, red!70, dashed}, domedge/.style={-{Latex[length=3mm]}, violet!70, dashed} ] % --- ZEITACHSE --- % Verschiebung nach oben (y=7) und Skalierung x (Faktor 3.2) \draw[->, thick, gray] (0, 7) -- (10.5, 7) node[right] {Time $t$}; \foreach \x in {0,1,2,3} \node[gray] at (\x*3.2, 7.3) {$t=\x$}; % --- KNOTEN --- % t=0 \node[labelnode] (start) at (0,0) { \textbf{Start} \nodepart{second} $V=0$\\$\omega=0$ }; % t=1 % Worker \node[optimal] (t1_w) at (3.2, 2.0) { \textbf{W1} \nodepart{second} $V=3$\\$\omega=1.0$\\$h=[1]$ }; % AI \node[labelnode] (t1_a) at (3.2, -2.0) { \textbf{A1} \nodepart{second} $V=1$\\$\omega=0.3$\\$h=[0]$ }; % t=2 % PATH A: \node[optimal] (t2_ww) at (6.4, 3.8) { \textbf{W $\to$ W} \nodepart{second} $V=6$\\$\omega=2.0$\\$h=[1,1]$ }; % PATH B: \node[labelnode] (t2_aw) at (6.4, 0) { \textbf{AI $\to$ W} \nodepart{second} $V=4$\\$\omega=1.3$\\$\mathbf{h=[0,1]}$ }; % PATH C: \node[dominated] (t2_wa) at (6.4, -2.5) { \textbf{W $\to$ AI} \nodepart{second} \textit{Dominated}\\$V=4$\\$\omega=1.3$\\$\mathbf{h=[1,0]}$ }; % PATH D: \node[infeasible] (t2_aa) at (6.4, -4.5) { \textbf{AI $\to$ AI} \nodepart{second} \textit{Pruned}\\$h=[0,0]$ }; % PATH A+: W -> W -> W \node[optimal] (t3_www) at (9.6, 4.8) { \textbf{3 Workers} \nodepart{second} $V=9$\\$\omega=3.0$\\Target Met }; % --- Arcs --- % t0 -> t1 \draw[optedge] (start) -- (t1_w) node[midway, above, sloped] {W (+3)}; \draw[ai] (start) -- (t1_a) node[midway, below, sloped] {AI (+1)}; % t1 -> t2 \draw[optedge] (t1_w) -- (t2_ww) node[midway, above, sloped] {W (+3)}; \draw[ai] (t1_w) -- (t2_wa) node[midway, below, sloped, pos=0.3] {AI (+1)}; \draw[worker] (t1_a) -- (t2_aw) node[midway, above, sloped, pos=0.4] {W (+3)}; \draw[prunededge] (t1_a) -- (t2_aa) node[midway, below, sloped] {Violation}; % t2 -> t3 \draw[optedge] (t2_ww) -- (t3_www) node[midway, above, sloped] {W (+3)}; % --- DOMINANCE --- \draw[->, violet, thick] (t2_aw) -- (t2_wa) node[midway, right, align=left, font=\scriptsize, xshift=2mm] {\textbf{Dominance Check}}; % --- NOTES BEREICH UNTER DEM PLOT --- \node[align=left, text width=12cm, anchor=north west, font=\sffamily\small] at (-0.5, -5.5) { \textbf{Notes:}\\ }; \end{tikzpicture} \caption{Your caption here} \label{fig:your-label} \end{figure} \lipsum[2] \end{document}
- Simulating language-related OpenType font featuresby Apothikon on December 12, 2025 at 10:03 am
In LuaLaTeX, is it possible to use babel (or anything else) to simulate some language-related OpenType features not defined in the font? I give an example of what I mean: Writing in ecclesiastical latin requires to put an acute accent on some vowels. On my Italian keyboard I've only the character é, thus typing á, í, ó, ú is quite inefficient. I would like to tell LaTeX that, inside an ecclesiasticallatin environment, whenever I type à, ì, ò, ù, it must be rendered as á, í, ó, ú. Thanks in advance.
- Draw line at right angleby user4035 on December 12, 2025 at 9:09 am
Code: \documentclass[12pt]{standalone} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[T2A]{fontenc} \usepackage{tikz} \usetikzlibrary{shapes, positioning, decorations.pathreplacing,calc,arrows} \begin{document} \begin{tikzpicture} \tikzset{ node/.style={draw, rectangle, rounded corners}, } \node [node] (excursions) {excursions}; \node [node, below right = 2.5cm of excursions] (excursions_cities_from) {excursions\_cities\_from}; \node [node, right = 3.5cm of excursions] (currencies) {currencies}; \draw[->] (currencies.west) -- node [below] {(id, currency\_id)} (excursions.east); \draw[->] (currencies.south) -> node [right] {(id, currency\_id)} (excursions_cities_from.north); \end{tikzpicture} \end{document} Is it possible to move the line \draw[->] (currencies.south) -> node [right] {(id, currency\_id)} (excursions_cities_from.north); to the position, indicated with red line? How to calculate coordinate from currencies.south - down until to top line of excursions_cities_from where the red arrow ends?
- What is the minimum set of commands to compile a plain tex file with UTF-8 Chinese characters to PDF?by merlin2011 on December 12, 2025 at 4:42 am
Consider the following minimum Tex example with Chinese characters: 你好 \bye I tried to compile it the traditional way, and it produces an blank document: tex Hello.tex dvipdf Hello.dvi I tried to compile it with xetex and get an error: sudo apt install texlive-xetex xetex Hello.tex This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023/Debian) (preloaded format=xetex) restricted \write18 enabled. kpathsea: Running mktexfmt xetex.fmt mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order): mktexfmt: /usr/share/texmf/web2c/fmtutil.cnf mktexfmt: /usr/share/texlive/texmf-dist/web2c/fmtutil.cnf mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes: mktexfmt: /home/hq6/.texlive2023/texmf-config/web2c/fmtutil.cnf mktexfmt [INFO]: writing formats under /home/hq6/.texlive2023/texmf-var/web2c mktexfmt [INFO]: Did not find entry for byfmt=xetex skipped mktexfmt [INFO]: not selected formats: 8 mktexfmt [INFO]: total formats: 8 mktexfmt [INFO]: exiting with status 0 I can't find the format file `xetex.fmt'! I tried running the command suggested in a different question and it completed successfully, but I still get the same error: sudo fmtutil-sys --all ... ... 50 preloaded fonts No pages of output. Transcript written on dviluatex.log. fmtutil [INFO]: log file copied to: /var/lib/texmf/web2c/luatex/dviluatex.log fmtutil [INFO]: /var/lib/texmf/web2c/luatex/dviluatex.fmt installed. fmtutil [INFO]: successfully rebuilt formats: 8 fmtutil [INFO]: total formats: 8 fmtutil [INFO]: exiting with status 0 How might I fix this error and compile the UTF-8 to PDF?
- Problem inputing a file into another with LuaLaTeXby Knudsen on December 12, 2025 at 2:55 am
I am trying to write a macro to input a set of small text files into a larger file, in lualatex, but seeing some variances how the text is inserted in the main file. So far I prepared this: \documentclass[11pt]{report} \usepackage{amsthm} \usepackage{polyglossia} \setmainfont{STIX Two Text} \usepackage[ a4paper, margin=4cm, marginparwidth=50pt, ]{geometry} \newtheoremstyle{problemstyle}% name of the style to be used {\topsep}% measure of space to leave above the theorem. E.g.: 3pt {\topsep}% measure of space to leave below the theorem. E.g.: 3pt {}% name of font to use in the body of the theorem {0pt}% measure of space to indent {\bfseries}% name of head font {}% punctuation between head and body { }% space after theorem head; " " = normal interword space {\thmname{#1}\thmnumber{ #2}\textbf{\thmnote{ (#3)}}} \theoremstyle{problemstyle} \newtheorem{problema}{\textbf{Problem}}[section] \newcommand{\bp}[1]{\begin{problema}[#1] \input{#1} \label{#1}\end{problema}} \begin{document} \bp{Fa87}% \begin{problema}[Fa87] Prove that $\cos^p \theta \leq \cos p\theta$ for $0 \leq \theta \leq \pi /2$ and $0 < p < 1$. \end{problema} \begin{problema}[Fa87] Prove that $\cos^p \theta \leq \cos p\theta$ for $0 \leq \theta \leq \pi /2$ and $0 < p < 1$. \end{problema} \begin{problema}[Fa87] Prove that $\cos^p \theta \leq \cos p\theta$ for $0 \leq \theta \leq \pi /2$ and $0 < p < 1$. \end{problema} \end{document} ẁith the text of Fa87 to be exactly Prove that $\cos^p \theta \leq \cos p\theta$ for $0 \leq \theta \leq \pi /2$ and $0 < p < 1$. all of it to be processed with lualatex. The variance can be seen here: where the spacing after the entry that uses the command \bp is about twice as much as the spacing of all others, entered directly into the text. Observe that the text introduced by the command is exactly the same as the one directly in the main file. The problem seems to be related to the text getting closer to the end of the line, but I fail to gresp how to address it.
- Official documentation of \pgfmathparse's behavior when processing a comma-separated list of ⟨expressions⟩?by Ulrich Diez on December 11, 2025 at 11:19 pm
\pgfmathparse{(1*2),(2+2),(sqrt(36))} yields defining \pgfmathresult as macro:->{2.0}{4.0}{6.00000} : \documentclass{article} \usepackage{tikz} \begin{document} \pgfmathparse{(1*2),(2+2),(sqrt(36))} \ttfamily \meaning\pgfmathresult \end{document} But this feature of processing a comma-separated list of ⟨expressions⟩ via \pgfmathparse in one go for obtaining a list of undelimited macro arguments seems not documented clearly/explicitly in pgfmanual.pdf. Precise syntax-rules for the quantity "⟨expression⟩", which is introduced and referred to in pgfmanual.pdf, seem to be missing, too. So the question is: Can you rely on \pgfmathparse calculating all components of a comma-separated tuple of independent ⟨expressions⟩ in one go and via \pgfmathresult delivering the results as a tuple of undelimited macro arguments? (In section "96 Customizing the Mathematical Engine" of the TikZ & PGF Manual for Version 3.1.11a you find: For functions with more than nine arguments, or functions with a variable number of arguments, these macros are only defined as taking one argument. The public macro expects its arguments to be comma separated, for example, \pgfmathVariableArgs{1.1,3.5,-1.5,2.6}. Each argument is parsed and passed on to the private macro as follows: \pgfmathVariableArgs@{{1.1}{3.5}{-1.5}{2.6}}. However, this does not exactly refer to \pgfmathparse/\pgfmathresult...)
- Multipart rectangle errorby ozsu on December 11, 2025 at 8:28 pm
I am having a problem with a multipart rectangle. I give a MWE below. At \nodepart{twentyone} {\scriptsize 00000000010}% and \nodepart{twentytwo} {\scriptsize 00000000001}% it complains error: 45: Missing number, treated as zero. \nodepart{twentyone} { Any reason? Is there a max limit on the boxes? \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{shapes.multipart} \begin{document} \begin{tikzpicture} \node[ rectangle split, rectangle split horizontal, rectangle split parts=22, draw, minimum height=1cm, align=center, rectangle split part fill={ % --- FIX: Added commas before the % comments --- green!50,green!50,green!50,green!50,green!50,green!50, % dict dates green!50,green!50,green!50,green!50,green!50, % (11 parts) yellow,yellow,yellow,yellow,yellow,yellow, % bitmaps yellow,yellow,yellow,yellow,yellow,yellow % (11 parts) } ] (recSt) {% % Dictionary (dates) \nodepart{one} {\scriptsize 2005-11-01}% \nodepart{two} {\scriptsize 1998-05-01}% \nodepart{three} {\scriptsize 2009-04-22}% \nodepart{four} {\scriptsize 1998-11-01}% \nodepart{five} {\scriptsize 2010-05-01}% \nodepart{six} {\scriptsize 2022-09-01}% \nodepart{seven} {\scriptsize 2021-03-18}% \nodepart{eight} {\scriptsize 2011-01-01}% \nodepart{nine} {\scriptsize 0216-07-01}% \nodepart{ten} {\scriptsize 2013-01-08}% \nodepart{eleven} {\scriptsize 2017-10-10}% % Bitmaps (one-hot) \nodepart{twelve} {\scriptsize 10000000000}% \nodepart{thirteen} {\scriptsize 01000000000}% \nodepart{fourteen} {\scriptsize 00100000000}% \nodepart{fifteen} {\scriptsize 00010000000}% \nodepart{sixteen} {\scriptsize 00001000000}% \nodepart{seventeen} {\scriptsize 00000100000}% \nodepart{eighteen} {\scriptsize 00000010000}% \nodepart{nineteen} {\scriptsize 00000001000}% \nodepart{twenty} {\scriptsize 00000000100}% \nodepart{twentyone} {\scriptsize 00000000010}% \nodepart{twentytwo} {\scriptsize 00000000001}% }; \end{tikzpicture} \end{document}
- Theorem numbers in smallcapsby xryophile on December 11, 2025 at 6:04 pm
I have sectioning elements in my documents in bold smallcaps of various sizes. I was hoping to be able to achieve this with my theorems, remarks, etc. as well. However, while this works for the labels (i.e. "Theorem", "Definition", etc.) for some reason the numbers remain in upshape (although they are bolded). Is there some way to "smallcap" the number too? Here is a minimal (not) working example: \documentclass{article} \usepackage{tgpagella} % Need a font with scshape \usepackage{amsthm,thmtools} \declaretheoremstyle[ headfont=\scshape\normalsize\bfseries, ]{definition} \declaretheorem[style=definition] {definition} \begin{document} \setcounter{definition}{2} % Difference is clear with 3 \begin{definition} Number is bold, but not \\smallcaps. Bold \emph{and} small caps: \textbf{\textsc{3}}. \end{definition} \end{document} The result is N.B. I've tried using the headformat key of declaretheoremstyle too, passing things like \textsc{\NUMBER}, but this doesn't seem to help. [Although it does work with \NAME.] N.B.B. I'm using thmtools for reasons I've omitted from this MWE, so if an answer is possible within the framework of this package that would be excellent. Of course, if it can be done internally in amsthm or ntheorem that would be fine too. On the other hand, even though it may be possible to simply write a whole theorem environment from scratch, I'm not at this point inclined to fix this (minor) issue in this way.
- Maximum, minimum, saddle and inflection pointsby Dimitrios ANAGNOSTOU on December 11, 2025 at 5:27 pm
I want to illustrate the different cases that can arise in a typical calculus course of functions of one variable. After searching a lot, I found a relevant question here. So, I am using the following code to plot a function for illustrating the various cases (local extremums, inflection and saddle points) along with the respective tangents. \documentclass[tikz,border=5pt]{standalone} \usepackage{pgfplots} \usetikzlibrary {intersections} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} \begin{axis}[ width=12cm, height=7cm, axis x line=middle, axis y line=middle, xlabel={$x$}, ylabel={$f(x)$}, xmin=-0.08, xmax=1.3, ymin=-0.008, ymax=0.01, samples=300, domain=-0.08:1.3, clip=false, xtick=\empty, ytick=\empty, xlabel style={at={(ticklabel cs:1)}, anchor=west}, ylabel style={at={(ticklabel cs:1)}, anchor=south} ] % === Polynomial (The function) === \addplot[very thick, blue, name path=poly] {(1/16)*x - (3/8)*x^2 + (37/48)*x^3 - (21/32)*x^4 + (1/5)*x^5}; % ======================================================= % === Critical points (f'(x)=0) and Horizontal Tangents === % Points: (0.125, 0.0033045), (0.5, -0.0009115), (1, 0.0020833) \addplot[only marks, mark=*, blue] coordinates { (0.125,0.0033045) (0.5,-0.0009115) (1,0.0020833) }; % Tangent segment 1 (Horizontal) \addplot[red, very thick, domain=-0.075:0.325, samples=2] {0.0033045}; % Tangent segment 2 (Horizontal) \addplot[red, very thick, domain=0.3:0.7, samples=2] { -0.0009115}; % Tangent segment 3 (Horizontal) \addplot[red, very thick, domain=0.8:1.2, samples=2] {0.0020833}; % ======================================================= % === Inflection points (f''(x)=0) and General Tangents === % Points: (0.2673, 0.0015571), (0.7014, 0.0004592) % Slopes: m1 ~ -0.019, m2 ~ 0.0104 \addplot[only marks, mark=*, orange] coordinates { (0.2673056,0.0015571) (0.7014444,0.0004592) }; % Tangent segment 4 (Inflection 1) \addplot[green, very thick, domain=0.0673:0.4673, samples=2] {-0.019*(x-0.2673056)+0.0015571}; % Tangent segment 5 (Inflection 2) \addplot[green, very thick, domain=0.5014:0.9014, samples=2] {0.0104*(x-0.7014444)+0.0004592}; % Origin label \node[anchor=north west] at (axis cs:0,0) {\small $O$}; \end{axis} \end{tikzpicture} \end{document} But this require a lot of manual calculations on my own. Is there a way or package to accelerate such calculus visualisations? A big thank you!
- Expansion of ~ in \index entriesby richard on December 11, 2025 at 1:36 pm
I have defined a command called \defn which formats its argument in bold and creates an index entry for it. I use it when defining a term in the text of the document. Here's a MWE showing a simplified version of it: \documentclass{book} \makeindex \newcommand\defn[1]{\textbf{#1}\index{#1}} \begin{document} I can write \defn{Q~set} instead of \textbf{Q~set}\index{Q~set}. \end{document} The problem arises in examples like the one above where I have a ~ in the index entry. (My publisher's house style is not to hyphenate this particular term and use a non-breaking space: it's not my choice.) My document, like the MWE above, has a mixture of instances of \defn and direct uses of \index where I don't want the bold formatting. However, they come out differently in the .idx file, meaning I get two identical looking index entries instead of one. This is what the MWE's .idx file looks like: \indexentry{Q\nobreakspace {}set}{1} \indexentry{Q~set}{1} I still want to be able to use \index directly as well as my \defn command. How do I fix the command or otherwise fix the code so that the two commands produce the same index entry? I've also tried changing the definition of \defn to use the TeX's \def built-in, in case this was a weirdness of how \newcommand works, but to no effect. I'm using XeLaTeX, but I've tested it in LaTeX which does the same.
- pin to some point on an arrowby Zarko on December 10, 2025 at 1:52 pm
Please consider the following MWE: \documentclass[tikz,border=3mm]{standalone} %---------------------------------------------------------------% \begin{document} %---------------------------------------------------------------% \begin{tikzpicture}[every pin edge/.style={<-, red}] \draw[->] (0, 1) -- (3,1); \draw[->] (0,0) -- (3,0) coordinate [pos=0.25, pin=210:X] (aux); \end{tikzpicture} %---------------------------------------------------------------% \end{document} Why the arrow head at the second line is moved to the point of pin position?
- nicematrix - Auto fill subblocksby projetmbc on December 10, 2025 at 9:16 am
I would like to factorize the code to avoid to manually type the a's, b's and m's. Is it possible? \documentclass{standalone} \usepackage{nicematrix} \usepackage[svgnames]{xcolor} \begin{document} $\begin{NiceArray}{ccccccccc}[cell-space-limits=2pt] &&&& & b_{11} & b_{12} & \Cdots & b_{1r} \\[5pt] &&&& & b_{21} & b_{22} & \Cdots & b_{2r} \\[5pt] &&&& & \Vdots & \Vdots && \Vdots \\[5pt] &&&& & b_{p1} & b_{p2} & \Cdots & b_{pr} \\%[5pt] \\%[5pt] a_{11} & a_{12} & \Cdots & a_{1p} & \hspace{20pt} & m_{11} & m_{12} & \Cdots & m_{1r} \\[5pt] a_{21} & a_{22} & \Cdots & a_{2p} & & m_{21} & m_{22} & \Cdots & m_{2r} \\[5pt] \Vdots & \Vdots && \Vdots & & \Vdots & \Vdots && \Vdots \\[5pt] a_{n1} & a_{n2} & \Cdots & a_{np} & & m_{n1} & m_{n2} & \Cdots & m_{nr} \\[5pt] \end{NiceArray}$ \end{document}
- Gradients in TikZby karlh on December 10, 2025 at 3:53 am
Based on the documentation, I would expect the two rectangles generated by this code to look identical: \documentclass{article} \usepackage{tikz} \begin{document} \pgfdeclarehorizontalshading{myshadingA} {1cm}{rgb(0cm)=(1,0,0); color(2cm)=(green); color(4cm)=(blue)} \begin{tikzpicture} \pgfuseshading{myshadingA} \shade [shading=myshadingA] (-2,-1) rectangle (2,-3); \end{tikzpicture} \end{document} However, this is clearly not the case. What am I doing wrong and/or misinterpreting in the documentation?
- How many expl3 code lines are in the LaTeX kernel?by TeXtnik on December 9, 2025 at 11:27 pm
I was courious to know how many line of expl3 code is in the LaTeX kernel. I run a python script (code below) to count the number of lines in each dtx file in the base directory of the LaTeX2e repository. The result I got is taht around 17% of the code is written in expl3. The breaking of this number for each file is below. I guess there are some improvements to be done: Don't count documentation lines. Include files in other directories (requires, tools ...) Use the striped tex files instead the dtx files? Some other? Can someone improve this estimate? (Apologize the use of python for these; I am force today to use a Windows machine, and I can't use some awk and shell tools to this work easier. I did it in a dirty way 🙁 ) total_lines expl3lines % alltt.dtx 224 0 0 classes.dtx 4505 0 0 doc.dtx 6293 517 8.2 docstrip.dtx 4603 0 0 exscale.dtx 202 0 0 fix-cm.dtx 829 0 0 fontdef.dtx 1623 0 0 graphpap.dtx 195 0 0 ifthen.dtx 558 0 0 inputenc.dtx 3053 0 0 latex209.dtx 1152 4 0.3 latexrelease.dtx 1355 237 17.5 latexsym.dtx 203 0 0 letter.dtx 1950 0 0 ltalloc.dtx 176 0 0 ltbibl.dtx 481 0 0 ltboxes.dtx 1622 0 0 ltclass.dtx 4171 2 0 ltcmd.dtx 5867 5753 98.1 ltcmdhooks.dtx 1865 1672 89.7 ltcntrl.dtx 326 0 0 ltcounts.dtx 881 0 0 ltdefns.dtx 2837 0 0 ltdirchk.dtx 1031 0 0 lterror.dtx 915 0 0 ltexpl.dtx 602 81 13.5 ltfilehook.dtx 1840 408 22.2 ltfiles.dtx 1842 20 1.1 ltfinal.dtx 1554 143 9.2 ltfloat.dtx 1690 0 0 ltfntcmd.dtx 806 0 0 ltfssaxes.dtx 4544 0 0 ltfssbas.dtx 2550 5 0.2 ltfsscmp.dtx 378 0 0 ltfssdcl.dtx 2234 131 5.9 ltfssini.dtx 2459 0 0 ltfsstrc.dtx 2053 25 1.2 lthooks.dtx 8160 5775 70.8 lthyphen.dtx 143 0 0 ltidxglo.dtx 218 0 0 ltkeys.dtx 740 573 77.4 ltlength.dtx 184 0 0 ltlists.dtx 1227 0 0 ltlogos.dtx 124 0 0 ltluatex.dtx 2201 0 0 ltmarks.dtx 2406 1519 63.1 ltmath.dtx 1483 0 0 ltmeta.dtx 251 81 32.3 ltmiscen.dtx 1899 0 0 ltoutenc.dtx 3861 0 0 ltoutput.dtx 6682 0 0 ltpage.dtx 438 41 9.4 ltpageno.dtx 101 0 0 ltpar.dtx 189 0 0 ltpara.dtx 1353 670 49.5 ltpictur.dtx 2046 0 0 ltplain.dtx 1745 0 0 ltproperties.dtx 1018 531 52.2 ltsect.dtx 1101 0 0 ltshipout.dtx 2270 1305 57.5 ltsockets.dtx 1218 459 37.7 ltspace.dtx 1500 0 0 lttab.dtx 1675 0 0 lttagging.dtx 1661 954 57.4 lttemplates.dtx 2830 2066 73 lttextcomp.dtx 2778 0 0 ltthm.dtx 319 0 0 ltvers.dtx 448 0 0 ltxdoc.dtx 728 0 0 ltxref.dtx 668 0 0 makeindx.dtx 313 0 0 newlfont.dtx 204 0 0 nfssfont.dtx 499 0 0 oldlfont.dtx 252 0 0 preload.dtx 269 0 0 proc.dtx 449 0 0 slides.dtx 2740 0 0 syntonly.dtx 282 0 0 utf8ienc.dtx 2327 0 0 Total 130469 22972 17.6 We can see that new features like ltcmd or the hook mechanism (ltchooks.dtx) are close to pure expl3. Despite the great work of the LaTeX project tema (small bang is getting bigger with the tagging), most parts of the kernel are not use expl3 at this moemnt. Are we going to see a 100% expl3 usage? Does this question make any sense? 😀 The code: import re import glob import pandas as pd def count_lines(filename): num_lines = sum(1 for _ in open(filename, encoding="utf8")) return num_lines starttag = "ExplSyntaxOn" endtag = "ExplSyntaxOff" pattern = rf"{starttag}(.*?){endtag}" # make pattern def count_expl3(filename): # get input with open(filename, "r", encoding="utf8") as fp: data = fp.read() # read in all the data to a string results = re.findall(pattern, data, flags=re.DOTALL) # DOTALL finds over multiple lines # print out results (you could write it to a file instead) find_lines = [] for res in results: for item in res.strip().split("\n"): find_lines.append(item) return len(find_lines) line_data = {} for latexfile in glob.glob("*.dtx"): total_lines = count_lines(latexfile) expl3_lines = count_expl3(latexfile) line_data[latexfile] = {"total_lines": total_lines, "expl3lines": expl3_lines} df = pd.DataFrame(line_data) df = df.head().transpose() df.loc['Total'] = df.sum(numeric_only=True) df['%'] = ((df["expl3lines"] / df["total_lines"]) * 100).round(1) print(df.to_markdown())
- Environment that conditionally collects its contentby campa on December 9, 2025 at 8:05 pm
Disclaimer: This is a bit a XY problem, or rather: I have a problem X and I have a solution Y which works but does not really make me happy. Background: I have an environment, say {foo}, which I use for school tests. In the environment I can have solutions, whose presence is controlled by a boolean \ifsolution. Sometimes I want to print the pupils' version: easy, set \solutionfalse. Sometimes I want to print my own version: also easy, use \solutiontrue. Sometimes, I want to have a pdf file which contains both versions, first without and and then with solution: also easy, just use the environ package or the b specifier to collect the content and print it twice. Problem: All three versions can be easily obtained by \NewDOcumentEnvironment{foo}{+b}{...}{...}. However, this breaks synctex, and that might be a bit annoying. My idea was therefore to define an environment that collects its argument only in the last case, when I need both versions. I've managed it like this: \documentclass{article} \newif\ifsolution \def\solution#1{\ifsolution#1\fi} \newtoks\mytoks \long\def\collectfoo#1\end#2{% \mytoks\expandafter{\the\mytoks#1}% \def\tempa{foo}% \def\tempb{#2}% \ifx\tempa\tempb \def\next{\end{foo}}% \else \def\next{\mytoks\expandafter{\the\mytoks\end{#2}}\collectfoo}% \fi \next } \newenvironment{foo}[1]{% \ifdefined\foox\errmessage{You cannot nest {foo}!}\else\let\foox\relax\fi \par \def\nextA{}% \def\nextB{}% \ifcase#1\relax\solutionfalse\or% 0 = without solution \solutiontrue\else% 1 = with solution \def\nextA{\mytoks{}\collectfoo}% else once with and once without \def\nextB{\solutionfalse\the\mytoks\par\solutiontrue\the\mytoks}\fi \nextA }{% \nextB \par } \begin{document} \begin{foo}{0} An environment to see if the scan works: \begin{itemize} \item bla \item bar \end{itemize} If I've done it right, there should be nothing here: \solution{foo bar baz} \end{foo} \vskip2ex\hrule\vskip2ex \begin{foo}{1} An environment to see if the scan works: \begin{itemize} \item bla \item bar \end{itemize} If I've done it right, there should be something here: \solution{foo bar baz} \end{foo} \vskip2ex\hrule\vskip2ex \begin{foo}{2} An environment to see if the scan works: \begin{itemize} \item bla \item bar \end{itemize} If I've done it right, this should appear twice, fist without and then with something here: \solution{foo bar baz} \end{foo} \end{document} The result is what I expect, but of course my way to collect the environment's content is very rough. (No environment stack like amsmath or environ.) The question is basically: can this be done better?
- drawing arc using intersection with triangleby troy on December 9, 2025 at 5:26 pm
I've been trying to adapt the answer https://tex.stackexchange.com/a/239471 to the drawing I've been attempting, but I'm getting a strange result. I want draw an arc that begins and ends where it intersects with a triangle and spanning the interior of the triangle. My attempt at this is below. What I'm getting is a small, almond-shaped loop near one of the intersections. \documentclass[tikz]{standalone} \usepackage{pgfplots} \usetikzlibrary{fillbetween} \usetikzlibrary{3d} \usetikzlibrary{calc} \usetikzlibrary{intersections} \usetikzlibrary{perspective} \begin{document} \begin{tikzpicture}[scale=1.25, font=\sffamily] \pgfmathsetmacro{\alphasma}{1.4} \coordinate (O) at (0,0,0); \node at (O) {O}; \begin{scope}[scale=4,purple,very thick] \coordinate (X) at (0,0,1); \coordinate (Y) at (1,0,0); \draw[->] (O) -- (Y) node[anchor=north east]{\Large Y}; \draw[->] (O) -- (X) node[anchor=south]{\Large X}; \end{scope} \begin{scope}[3d view={90}{0.1}] \begin{scope}[scale=5,orange] \begin{scope}[rotate around y=20,black] \begin{scope}[rotate around z=-10,cyan] \begin{scope}[ canvas is xy plane at z=0, very thick ] \path[name path=lambdaArc] (O) circle [x radius=.95,y radius=.45]; \draw[name path=O-X-Y,dashed] (O) -- ($(O)!2*\alphasma!(X)$) -- ($(O)!2*\alphasma!(Y)$) -- cycle; \draw[red,thin, intersection segments={of=lambdaArc and O-X-Y,sequence=L3}]; \draw[orange,dashed] (O) circle [x radius=.95,y radius=.45]; \end{scope} \end{scope} \end{scope} \end{scope} \end{scope} \end{tikzpicture} \end{document} This is part of a larger diagram I am making. Deleting the extraneous parts leaves some scopes and structure that look unnecessary, but I left them as-is.