Week
- Automatically include -converted version of images in LaTeX if it existsby monty01 on March 14, 2026 at 1:11 pm
I'm working on a LaTeX document where I have multiple image files, some of which have a -converted version. For example, my files might look like this: a.png b.png b-converted.png c.png c-converted.png d.png I want to include the images in my document using a command like: \includegraphics{a.png} % includes a.png \includegraphics{b.png} % include b-converted.png \includegraphics{c.png} % include c-converted.png \includegraphics{d.png} % includes d.png That is, the logic should be: If basename-converted.ext exists, include that. Otherwise, include the original file: basename.ext. MWE \documentclass{article} \usepackage{graphicx} \begin{document} \includegraphics{a.png} \includegraphics{b-converted.png} \end{document} EDIT: I should work with multiple multiple file extension, like png, jpg, pdf, svg ...
- Drawing distorted circleby Miguel Forteza on March 14, 2026 at 12:14 pm
I was trying to copy this figure (from Elementary Classic Analysis Marsden Hoffman): And I don't know how. I've already seen various posts about a distorted circles where they drawed it randomly and I tried it but the result I get it's not quite like I want. I want like it's a sketch of a set I could have drawn (like the picture), but I get a circle "that has random noise". I know that making figures can be hard (at least for me) so if someone could just give me some indications I'd be really grateful.
- Detecting missing graphics across a large LaTeX repositoryby JeT on March 14, 2026 at 10:14 am
is there a TeX-based solution or is external tooling required? Like many of you (I suppose), I maintain a relatively large LaTeX repository used to produce lecture slides and course material. The project has grown over several years and now contains several hundred .tex files twice as many graphics (.png, .pdf) nested directories shared figures reused across multiple documents Typical usage is simply \documentclass{article} \usepackage{graphicx} \begin{document} \includegraphics{figures/payoff_diagram.png} \end{document} As the project evolves, files are sometimes moved or renamed. When this happens, some paths referenced by \includegraphics become invalid. Maintaining a clean path becomes a nightmare... In practice this leads to two types of issues graphics referenced in .tex files that no longer exist graphics present in the repository but not used anywhere Compiling documents eventually reveals missing files, but in a large repository this becomes slow and inconvenient. So my question is essentially about project-level integrity checks. Is there a way within the TeX ecosystem to automatically audit a repository and detect files referenced by \includegraphics that do not exist graphics present in the repository but never referenced For example Does LaTeX provide tooling to inspect file dependencies across a project Are there packages or TeX utilities designed for this Or is the typical solution to rely on external tooling such as scripts or CI workflows More broadly, with the recent development of automation tools and AI-assisted repository analysis, I am also wondering whether people have started using such approaches to maintain consistency in large LaTeX projects. I would be interested in knowing what workflows people use in practice for this type of problem.
- Any luacode regex patch method to detect greeks letters?by Explorer on March 14, 2026 at 7:57 am
Learning from Mico's answer, I have the following code to add \, between number and letter automaticlly via: s:gsub ( "(%d)(%a)" , "%1\\,%2" ) Here below is the code: \documentclass{article}% lualatex required \usepackage{amsmath,amssymb} \usepackage{luacode} \begin{luacode} function digit_letter_spacer ( s ) return s:gsub ( "(%d)(%a)" , "%1\\,%2" ) end \end{luacode} \newcommand\DigitLetterSpaceOn{\directlua{luatexbase.add_to_callback ( "process_input_buffer" , digit_letter_spacer , "DigitLetterSpace" )}} \newcommand\DigitLetterSpaceOff{\directlua{luatexbase.remove_from_callback ( "process_input_buffer" , "DigitLetterSpace" )}} \AtBeginDocument{\DigitLetterSpaceOn} \begin{document} 23x $23x$ 1a2b3c $E=mc^2$ \[ 23x + 45y - 6z = 114qwq\] \begin{align*} \sum_{i=3n}^{\infty} \frac{5x}{7y} - \sqrt{100w} &\cong 3\mathbb{R} \\ 3x^2+4y^2&=5z^2 \end{align*} While the greek letter is not detected: $5\lambda+6\kappa=7\eta$ \begin{gather} 5\alpha+6\beta=7\gamma \end{gather} \end{document} However, the greek letter is not reconginzed. Any approach to regard Greeks Letter as letters in luacode?
- How to make \textrightarrow use the Roboto font in LaTeX?by monty01 on March 13, 2026 at 8:09 pm
I am trying to use the Roboto font everywhere in my LaTeX document. I load it using the roboto package: \documentclass{article} \usepackage[sfdefault]{roboto} \begin{document} Some random text A \textrightarrow\ B Some random text \end{document} However, the arrow produced by \textrightarrow does not seem to come from the Roboto font. It looks different from the surrounding text. How can I make \textrightarrow use the Roboto so that it matches the rest of the document?
- Trig label Issues on Graphby Nick B on March 13, 2026 at 1:07 pm
I am trying to recreate this picture from the College Board. I am able to recreate the image with the x-axis labeled in fourths (pi). However, the original shows each label being 1/8 (pi). Each time I try to use specific xtick and xlabel, the spacing is incorrect. Is there an easier way I can do this? Here is my code: \documentclass[12pt]{article} \usepackage{fullpage,parskip,pgfplots} \pgfplotsset{compat=newest} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture} \begin{axis}[ axis lines=middle, axis equal, clip=false, enlargelimits=false, xlabel={\(x\)}, ylabel={\(y\)}, title={Graph of \(f\)}, grid=major, grid style={black!75}, xmin=-2*pi/3,xmax=13*pi/6, ymin=-5,ymax=4, xtick={-0.75*pi, -0.5*pi, -0.25*pi, 0, 0.25*pi, 0.5*pi, 0.75*pi, pi, 1.25*pi, 1.5*pi, 1.75*pi, 2*pi, 2.25*pi}, xticklabels={, $-\frac{\pi}{2}$, , , , $\frac{\pi}{2}$, , $\pi$, , $\frac{3\pi}{2}$, , $2\pi$, }, ytick={-5, -4, -3, -2, -1, 0, 1, 2, 3, 4}, yticklabels={\(-5\), , \(-3\), , \(-1\), , \(1\), , \(3\)}, title style={ font=\Large, anchor=north, at={(rel axis cs: 0.5,0)}, yshift=-3mm, }, ticklabel style={fill=white}, axis line style={ thick,-{Triangle[length=3mm,width=2mm]},shorten >=-4mm,}, ticklabel style={fill=white, inner sep=1pt, font=\normalsize}, ] \addplot[samples=100,thick,domain=-2.09:6.54]{3*sin(deg(2*x-pi/2))}; \end{axis} \end{tikzpicture} \end{document} Any help would be appreciated. TYA
- landscape success, but page numbering and footer still in portrait modeby user516076 on March 13, 2026 at 1:32 am
My wish List: I want. for footer starts from page 2 (landscape) it has : © Arrohmah Bogor 2026 (on the bottom left) aligned to margin. 0580/02/UT/2026 on the bottom centre starts from page 2 to 5, (I can change 5 to page number greater or lower than that) 0580/04/UT/2026 on the bottom centre starts from page 5 to end, (I can change 5 to page number greater or lower than that according to the previous scheme) Turn Over (on the bottom right aligned to margin. and only applies to odd pages) for header: starts from page 2 (landscape) it has: 0580/02 (on top most left aligned to margin, from page 2 to 5, (I can change 5 to page number greater or lower than that)) 0580/04 (on top most left aligned to margin, from page 5 to end, (I can change 5 to page number greater or lower than that)) Cambridge IGCSE - Mark Scheme\\textbf{UNIT TEST} (on top most centre) For examination\\From 2026 (on right most centre aligned to margin) \\ means enter newline. This code still has portrait page numbering and footer: \documentclass[12pt,twoside]{article} \usepackage[ a4paper, hmargin=2cm, vmargin=1.8cm ]{geometry} \usepackage{graphicx} \usepackage{tikz} \usepackage{enumitem} \usepackage{setspace} \usepackage[export]{adjustbox} \usepackage{fancyhdr} \usepackage{lipsum} \usepackage{array} \usepackage{amsmath} \usepackage{marginnote} \usetikzlibrary{calc} \usepackage{refcount} \usepackage{lastpage} \usepackage{pdflscape} \pagestyle{empty} \newcommand{\commandpage}{\pageref{LastPage}} %==================== PAGE STYLE FROM PAGE 2 ONWARD ==================== \fancypagestyle{mypages}{ \fancyhf{} \fancyhead[C]{\thepage} \fancyfoot[L]{\small © Arrohmah Bogor 2026} \fancyfoot[C]{\small 0580/02-04/MS/26} \fancyfoot[RO]{\small \textbf{[Turn Over]}} \renewcommand{\headrulewidth}{0pt} } \newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}} \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}} \begin{document} %==================== LOGOS ==================== \begingroup \setlength{\parindent}{0pt} \vspace*{-1.7cm} \begin{tabular}{@{}p{0.2\textwidth}@{}p{0.8\textwidth}@{}} \hspace*{-.25cm}\includegraphics[height=2.2cm,valign=m]{newarrohmah.png} & \hfill \includegraphics[trim=0 150 0 150,scale=.30,valign=m]{cambridge.png}\hspace*{-1cm} \end{tabular} \vspace{1cm} {\LARGE \textbf{Cambridge IGCSE\texttrademark}}% \vspace{10pt} Teacher : Mr. Shandy \vspace{0.6cm} \vspace{10pt} %==================== PAPER HEADER ==================== \hrule \begin{tabular}{@{}p{0.8\textwidth}@{}p{0.2\textwidth}@{}} \vspace*{-1mm} \textbf{MATHEMATICS} Paper 2 Non-calculator and Paper 4 Calculator (Extended) \vspace{2pt} MARK SCHEME \vspace{2pt} Maximum Mark: 100 & \raggedleft \vspace{-1mm} \textbf{0580/02} \textbf{March 2026} \textbf{2 hours} \end{tabular} \endgroup \vspace{3pt} \hrule \vspace{7in} \hrule \begin{center} This document has \textbf{\commandpage} pages. \end{center} \noindent \begin{tabular}{@{}p{0.5\textwidth}@{}p{0.5\textwidth}@{}} {\small © Arrohmah Bogor 2026} & \raggedleft {\small \textbf{[Turn Over]}} \end{tabular} \newpage %==================== PAGE 2 ONWARD LANDSCAPE ==================== \begin{landscape} \pagestyle{mypages} \lipsum \end{landscape} \end{document} Trying to implement this reference as my best attempt, ended up with this update: \documentclass[12pt,twoside]{article} \usepackage[ a4paper, hmargin=2cm, vmargin=1.8cm ]{geometry} \usepackage{graphicx} \usepackage{tikz} \usepackage{enumitem} \usepackage{setspace} \usepackage[export]{adjustbox} \usepackage{fancyhdr} \usepackage{lipsum} \usepackage{array} \usepackage{amsmath} \usepackage{marginnote} \usetikzlibrary{calc} \usepackage{refcount} \usepackage{lastpage} \usepackage{pdflscape} \usepackage{everypage} \pagestyle{empty} \newcommand{\commandpage}{\pageref{LastPage}} %==================== PAGE STYLE FROM PAGE 2 ONWARD ==================== \fancypagestyle{mypages}{ \fancyhf{} \fancyhead[C]{\thepage} \fancyfoot[L]{\small © Arrohmah Bogor 2026} \fancyfoot[C]{\small 0580/02-04/MS/26} \fancyfoot[RO]{\small \textbf{[Turn Over]}} \renewcommand{\headrulewidth}{0pt} } \newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}} \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}} % ---------- Rotated footer for landscape pages ---------- \newlength{\hfoot} \newlength{\vfoot} \AddEverypageHook{% \ifdim\textwidth=\linewidth\relax % portrait page -> do nothing \else % landscape page \setlength{\hfoot}{-\topmargin}% \addtolength{\hfoot}{-\headheight}% \addtolength{\hfoot}{-\headsep}% \addtolength{\hfoot}{-.5\linewidth}% \ifodd\value{page} \setlength{\vfoot}{\oddsidemargin}% \else \setlength{\vfoot}{\evensidemargin}% \fi \addtolength{\vfoot}{\textheight}% \addtolength{\vfoot}{\footskip}% \raisebox{\hfoot}[0pt][0pt]{% \rlap{% \hspace{\vfoot}% \rotatebox[origin=cB]{90}{% \makebox[\textheight][c]{% \small © Arrohmah Bogor 2026\hfill \thepage\hfill 0580/02-04/MS/26\hfill \textbf{[Turn Over]}% }% }% }% }% \fi } \begin{document} %==================== LOGOS ==================== \begingroup \setlength{\parindent}{0pt} \vspace*{-1.7cm} \begin{tabular}{@{}p{0.2\textwidth}@{}p{0.8\textwidth}@{}} \hspace*{-.25cm}\includegraphics[height=2.2cm,valign=m]{newarrohmah.png} & \hfill \includegraphics[trim=0 150 0 150,scale=.30,valign=m]{cambridge.png}\hspace*{-1cm} \end{tabular} \vspace{1cm} {\LARGE \textbf{Cambridge IGCSE\texttrademark}}% \vspace{10pt} Teacher : Mr. Shandy \vspace{0.6cm} \vspace{10pt} %==================== PAPER HEADER ==================== \hrule \begin{tabular}{@{}p{0.8\textwidth}@{}p{0.2\textwidth}@{}} \vspace*{-1mm} \textbf{MATHEMATICS} Paper 2 Non-calculator and Paper 4 Calculator (Extended) \vspace{2pt} MARK SCHEME \vspace{2pt} Maximum Mark: 100 & \raggedleft \vspace{-1mm} \textbf{0580/02} \textbf{March 2026} \textbf{2 hours} \end{tabular} \endgroup \vspace{3pt} \hrule \vspace{7in} \hrule \begin{center} This document has \textbf{\commandpage} pages. \end{center} \noindent \begin{tabular}{@{}p{0.5\textwidth}@{}p{0.5\textwidth}@{}} {\small © Arrohmah Bogor 2026} & \raggedleft {\small \textbf{[Turn Over]}} \end{tabular} \newpage %==================== PAGE 2 ONWARD LANDSCAPE ==================== \begin{landscape} \pagestyle{empty} \lipsum[1-8] \newpage \lipsum[9-16] \end{landscape} \end{document} Givng me this result: It's kind of working, but I want the Arrohmah on the left aligning the outer first margin and the Turn Over (odds only) the most right part aligning the margin from the left. The paper code on bottom most centre and the page numbering on top most centre. (Exactly just like the portrait, but this for landscape that starts from page 2 to the end). EDIT: This is the stripped version and the updated version from the suggestion by @Explorer. But still a disaster: \documentclass[12pt,twoside]{article} \usepackage[a4paper,hmargin=2cm,vmargin=1.8cm]{geometry} \usepackage{lipsum} \usepackage{lastpage} \usepackage{pdflscape} \pagestyle{empty} \newcommand{\commandpage}{\pageref{LastPage}} \newcommand{\switchpage}{5} \newcommand{\leftheadercode}{% \ifnum\value{page}<\switchpage 0580/02\else 0580/04\fi } \newcommand{\centrefootercode}{% \ifnum\value{page}<\switchpage 0580/02/UT/2026\else 0580/04/UT/2026\fi } \ExplSyntaxOn \bool_new:N \l_landscape_bool \coffin_new:N \l_footer_coffin \coffin_new:N \l_header_left_coffin \coffin_new:N \l_header_center_coffin \coffin_new:N \l_header_right_coffin \dim_new:N \g_saved_textwidth_dim \dim_new:N \g_saved_textheight_dim \hook_gput_code:nnn { begindocument/end } { . } { \dim_gset:Nn \g_saved_textwidth_dim { \textwidth } \dim_gset:Nn \g_saved_textheight_dim { \textheight } } \hook_gput_code:nnn { env/landscape/begin } { . } { \bool_set_true:N \l_landscape_bool } \hook_gput_code:nnn { env/landscape/end } { . } { \bool_set_false:N \l_landscape_bool } \hook_gput_code:nnn { shipout/background } { . } { \bool_if:NT \l_landscape_bool { \hcoffin_set:Nn \l_header_left_coffin { \small \leftheadercode } \coffin_rotate:Nn \l_header_left_coffin { 90 } \vcoffin_set:Nnn \l_header_center_coffin { 4cm } { \centering \small Cambridge IGCSE - Mark Scheme \\ \small \textbf{UNIT TEST} } \coffin_rotate:Nn \l_header_center_coffin { 90 } \vcoffin_set:Nnn \l_header_right_coffin { 3.5cm } { \raggedleft \small For examination \\ \small From 2026 } \coffin_rotate:Nn \l_header_right_coffin { 90 } \hcoffin_set:Nn \l_footer_coffin { \small © Arrohmah Bogor 2026 \hspace*{\fill} \centrefootercode \hspace*{\fill} \ifodd\value{page}\textbf{[Turn Over]}\fi } \coffin_rotate:Nn \l_footer_coffin { 90 } \put ( \dim_eval:n { \oddsidemargin + 1in - \headsep }, \dim_eval:n { -1in - \topmargin - \headheight - 8pt } ) { \coffin_typeset:Nnnnn \l_header_left_coffin { b } { hc } { 0pt } { 0pt } } \put ( \dim_eval:n { \oddsidemargin + 1in + 0.5\g_saved_textwidth_dim }, \dim_eval:n { -1in - \topmargin - \headheight - 8pt } ) { \coffin_typeset:Nnnnn \l_header_center_coffin { b } { hc } { 0pt } { 0pt } } \put ( \dim_eval:n { \oddsidemargin + 1in + \g_saved_textwidth_dim + \headsep }, \dim_eval:n { -1in - \topmargin - \headheight - 8pt } ) { \coffin_typeset:Nnnnn \l_header_right_coffin { b } { hc } { 0pt } { 0pt } } \put ( \dim_eval:n { \footskip + \oddsidemargin + 1in + \g_saved_textwidth_dim }, \dim_eval:n { -1in - \topmargin - 0.5\g_saved_textheight_dim - \headheight - \headsep } ) { \coffin_typeset:Nnnnn \l_footer_coffin { t } { hc } { 0pt } { 0pt } } } } \ExplSyntaxOff \begin{document} Page 1 \begin{center} This document has \textbf{\commandpage} pages. \end{center} \newpage \begin{landscape} \lipsum[1-8] \newpage \lipsum[9-16] \end{landscape} \end{document} Latest attempt (screenshot): Last Edit: This may be the last edit. I just can't. No matter what I've tried it never gave me success. I guess considering to use M. Word is the best idea :') \documentclass[12pt,twoside]{article} \usepackage[ a4paper, hmargin=2cm, vmargin=1.8cm, headheight=30pt ]{geometry} \usepackage{graphicx} \usepackage{tikz} \usepackage{enumitem} \usepackage{setspace} \usepackage[export]{adjustbox} \usepackage{fancyhdr} \usepackage{lipsum} \usepackage{array} \usepackage{amsmath} \usepackage{marginnote} \usetikzlibrary{calc} \usepackage{refcount} \usepackage{lastpage} \usepackage[pdftex]{lscape} \pagestyle{empty} \newcommand{\commandpage}{\pageref{LastPage}} \newcommand{\switchpage}{5} \newcommand{\leftheadercode}{% \ifnum\value{page}<\switchpage 0580/02% \else 0580/04% \fi } \newcommand{\centrefootercode}{% \ifnum\value{page}<\switchpage 0580/02/UT/2026% \else 0580/04/UT/2026% \fi } \fancypagestyle{landscapepages}{% \fancyhf{} \fancyhead[LE,LO]{\small\leftheadercode} \fancyhead[CE,CO]{\small\shortstack[c]{Cambridge IGCSE - Mark Scheme\\\textbf{UNIT TEST}}} \fancyhead[RE,RO]{\small\shortstack[r]{For examination\\From 2026}} \fancyfoot[LE,LO]{\small © Arrohmah Bogor 2026} \fancyfoot[CE,CO]{\small\centrefootercode} \fancyfoot[RE,RO]{\small\ifodd\value{page}\textbf{[Turn Over]}\fi} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} } \newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}} \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}} \newcommand{\switchtolandscape}{% \clearpage \newgeometry{ paperwidth=297mm, paperheight=210mm, left=2cm, right=2cm, top=1.8cm, bottom=1.8cm, headheight=30pt }% \pdfpagewidth=\paperwidth \pdfpageheight=\paperheight \setlength{\headwidth}{\textwidth} \pagestyle{landscapepages} } \begin{document} %==================== LOGOS ==================== \begingroup \setlength{\parindent}{0pt} \vspace*{-1.7cm} \begin{tabular}{@{}p{0.2\textwidth}@{}p{0.8\textwidth}@{}} \hspace*{-.25cm}\includegraphics[height=2.2cm,valign=m]{newarrohmah.png} & \hfill \includegraphics[trim=0 150 0 150,scale=.30,valign=m]{cambridge.png}\hspace*{-1cm} \end{tabular} \vspace{1cm} {\LARGE \textbf{Cambridge IGCSE\texttrademark}}% \vspace{10pt} Teacher : Mr. Shandy \vspace{0.6cm} \vspace{10pt} %==================== PAPER HEADER ==================== \hrule \begin{tabular}{@{}p{0.8\textwidth}@{}p{0.2\textwidth}@{}} \vspace*{-1mm} \textbf{MATHEMATICS} Paper 2 Non-calculator and Paper 4 Calculator (Extended) \vspace{2pt} MARK SCHEME \vspace{2pt} Maximum Mark: 100 & \raggedleft \vspace{-1mm} \textbf{0580/02} \textbf{March 2026} \textbf{2 hours} \end{tabular} \endgroup \vspace{3pt} \hrule \vspace{7in} \hrule \begin{center} This document has \textbf{\commandpage} pages. \end{center} \noindent \begin{tabular}{@{}p{0.5\textwidth}@{}p{0.5\textwidth}@{}} {\small © Arrohmah Bogor 2026} & \raggedleft {\small \textbf{[Turn Over]}} \end{tabular} \switchtolandscape \lipsum[1-8] \newpage \lipsum[9-16] \lipsum \lipsum[1-50] \end{document}
- Drawing a Manifold in tikzby Hassium on March 12, 2026 at 8:21 pm
I am trying to draw a manifold using tikz. The best way I can think of is to give several points and generates smooth lines connecting those points. Here is my draft: \documentclass{article} \usepackage{amsmath,amssymb,amsthm} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw[thick] plot [smooth cycle, tension=1] coordinates { (-2.5,0) (-1.6,1) (0,0.55) (1.6,1) (2.5,0) (1.6,-1) (0,-0.55) (-1.6,-1) }; \draw[thick] (-1.85, -0.05) to[out=-30, in=210] (-0.95, -0.05); \draw[thick] (-1.7, -0.1) to[out=45, in=135] (-1.1, -0.1); \end{tikzpicture} \end{document} The lines are not very smooth. Is there a way to make the lines more smooth? Or is there a better strategy to draw this? Thanks in advance.
- Count spaces in LaTeXby Vincent on March 12, 2026 at 7:11 pm
I would like to create a fast/optimized fully expandable function that counts the number of spaces in an argument: \documentclass{article} \begin{document} \countspaces{ A B } % Should return 3 (1 is ok too if leading and trailing spaces are removed) \countspaces{A \mycommand B} % Should return 2 (\mycommand is not expanded) \countspaces{A {a b c} B} % Should return 2 (spaces inside groups are not counted) \end{document} Explicit spaces should be counted too. How to achieve that?
- define macros inside externalized tikzby Thomas on March 12, 2026 at 3:09 pm
I have a big document that takes some time to compile, mostly due to a lot of pgfplots figures in which I compute linear regressions etc. I just discovered the TikZ library external, which allows to pre-compile the figures, so it is not done on the fly at each time I compiled the document (each time I save). In one of the figure, I'm creating a macro with \xdef to retrieve the slope of the linear regression to display the value in the text afterwards. But when the externalize is enabled, the macro is no longer accessible outside, resulting in an undefined error. Here is a MWE, where I oversimplified the code (but the idea is the same in my huge pgfplots figure) \documentclass[10pt]{article} \usepackage{tikz} \usetikzlibrary{external} \tikzexternalize \begin{document} \begin{tikzpicture} \xdef\slope{3.2} \draw (0,0) node[draw]{Slope is \slope}; \end{tikzpicture} Outside tikzpicture: \slope \end{document} If I deactivate tikzexternalize, I see the correct number on the line "Outside tikzpicture", but when I set it back, I get the error. A workaround that I found to get rid of the error would be to add \xdef\slope{n/a} in the preamble, so when I compile with externalize the macro is found and the compilation goes on, but this is not optimal...
- Problem with multicols in tcolorboxby CasperYC on March 12, 2026 at 11:10 am
\documentclass[a4paper,12pt, scheme = plain]{ctexart} \usepackage{amsmath,enumerate} \usepackage[export]{adjustbox} % uses graphicx \usepackage{graphicx} \usepackage{xcolor} \usepackage[margin = 1.5cm]{geometry} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{tcolorbox} \tcbuselibrary{skins,xparse,breakable,listings} \tcbset{% colback = white, colframe = black, title filled = false, colbacktitle = white, % 框的背景 enhanced, breakable }%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NewTColorBox[ auto counter, number freestyle = {Example \,\noexpand\arabic{\tcbcounter} }, ]{question}{ O{}mo }{ fonttitle = \bfseries, title = \thetcbcounter: #2, % 显示source coltitle = black, % 标题的颜色 (默认白色背景!!!!!) before lower = {\textbf{Solution:} \par}, #1 }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{multicol} % cover page multicol \setlength{\columnsep}{3cm} \setlength{\columnseprule}{1pt} \def\columnseprulecolor{\color{blue}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\d{{\rm d}} \newcommand{\qaq}{\quad \text{and} \quad} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{question}{Integrating $\sin^2(x)$ and $\cos^2(x)$} Find \[ \int \sin^2(x) \, \d x \qaq \int \cos^2(x) \, \d x \] \tcblower%% \phantom{aaa} \begin{multicols}{2} \begin{align*} \int \sin^2(x) \, \d x &= \int \frac{1}{2} - \frac{1}{2} \cos(2x) \, \d x \\ &= \frac{1}{2}x - \frac{1}{4} \sin(2x) + \text{constant} \end{align*} \begin{align*} \int \cos^2(x) \, \d x &= \int \frac{1}{2} + \frac{1}{2} \cos(2x) \, \d x \\ &= \frac{1}{2}x + \frac{1}{4} \sin(2x) + \text{constant} \end{align*} \end{multicols} \end{question} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{enumerate} \item \phantom{aaa} \begin{question}{Integrating $\sin^2(x)$ and $\cos^2(x)$} Find \[ \int \sin^2(x) \, \d x \qaq \int \cos^2(x) \, \d x \] \tcblower%% \begin{multicols}{2} \begin{align*} \int \sin^2(x) \, \d x &= \int \frac{1}{2} - \frac{1}{2} \cos(2x) \, \d x \\ &= \frac{1}{2}x - \frac{1}{4} \sin(2x) + \text{constant} \end{align*} \begin{align*} \int \cos^2(x) \, \d x &= \int \frac{1}{2} + \frac{1}{2} \cos(2x) \, \d x \\ &= \frac{1}{2}x + \frac{1}{4} \sin(2x) + \text{constant} \end{align*} \end{multicols} \end{question} \end{enumerate} \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The normal case is okish, except that the margin is a bit over. And in the enumerate environment, it gets even worse. In both cases, the horizontal baselines do not seem to agree either...
- How to create lines perfectly lie on a circle shape with TikZ?by user516076 on March 12, 2026 at 6:49 am
It's very difficult to make a perfect line that lies on exact circle. This is my full work: \documentclass[tikz,border=1pt]{standalone} \usepackage{tikz} \usepackage{calligra} \usepackage[T1]{fontenc} \begin{document} \begin{tikzpicture}[line width=1pt] \path[use as bounding box] (-5.6,-1.2) rectangle (6.4,7.2); % Circle \draw (2.6,3.0) circle (3.1); % Secant line P-T-U \draw (-5.0,0.1) -- (4.7,5.6); % Chords \draw (2.6,2.3) -- (1.2,1.7); % short chord near S \draw (1.2,1.7) -- (4.0,1.4); % S to V \draw (4.0,1.4) -- (4.7,5.6); % V to U % Angle at S \draw (1.2,1.7) ++(0.55,0) arc[start angle=0,end angle=123,radius=0.55]; % Angle at V \draw (4.0,1.4) ++(-0.55,0) arc[start angle=180,end angle=95,radius=0.55]; % Labels \node[font=\fontsize{34}{34}\selectfont] at (-5.0,-0.4) {$P$}; \node[font=\fontsize{34}{34}\selectfont] at (0.2,2.9) {$T$}; \node[font=\fontsize{34}{34}\selectfont] at (5.2,5.9) {$U$}; \node[font=\fontsize{34}{34}\selectfont] at (4.3,0.4) {$V$}; \node[font=\fontsize{34}{34}\selectfont] at (0.9,0.7) {$S$}; % Angle labels \node[font=\fontsize{28}{28}\selectfont] at (2.0,2.5) {$123^\circ$}; \node[font=\fontsize{28}{28}\selectfont] at (3.6,2.0) {$85^\circ$}; \end{tikzpicture} \end{document} and this is the result: What I want: Please along with full MWE ready to copy paste, could you explain, what the trick is and what to add and where to add, so that I can also learn? T.I.A.
- how to trim inside TikZ?by user516076 on March 12, 2026 at 1:13 am
MWE: \documentclass[tikz,border=1pt]{standalone} \usepackage{tikz} \usepackage{calligra} \usepackage[T1]{fontenc} \begin{document} \begin{tikzpicture}[line width=1pt] % \path[use as bounding box] (1,0) rectangle (12,7); % Outer rectangle \draw (0,0) rectangle (12,7); % Curvy E outside the box \node[anchor=center, font=\calligra\fontsize{38}{38}\selectfont] at (-1.5,6.75) {E}; % Left circle \draw (4.0,3.4) circle (2.75); % Right circle \draw (8.25,3.45) circle (2.2); % Labels \node[font=\fontsize{28}{28}\selectfont] at (1.8,5.8) {$P$}; \node[font=\fontsize{28}{28}\selectfont] at (9.4,5.9) {$Q$}; \end{tikzpicture} \end{document} This gives me this picture: There, you see a white space on the left that needs to be trimmed. My best knowledge is using: \path[use as bounding box] (1,0) rectangle (12,7); but it gives me: I want to control it like 1pt or 2pt or 1cm, 2cm to mean that I trim that much. How to do that? I tried to control (1,0), but it doesn't work as I expected. Also, if possible, I don't want to crop it outside, like using \includegraphs and trim it. It is saving time to trim it inside the TikZ, IMHO.
- Counting total award pointsby user516076 on March 12, 2026 at 12:31 am
As a teacher, you might find this question relatable should you be bothered by making sure that the sum of marks is a certain number when you make an exam. Since I believe LaTeX has control flow, I think it would be great to have a feature to count how many marks I have made so far. So, in this particular document, if it is possible, could I have a mini program that would print a number of sum of the marks? If I exceed the number of max marks, it will give a warning that been printed out below the instruction. just like if else condition. To ilustrate it, Suppose my first problem gives [3] marks, second problem has [4] marks, third problem has [1] mark and the last problem has [6] marks. I want a command to print the sum of them in a sentence like this: The total mark for this paper is \mark. Is this doable? How to? I'll just provide this MWE and let you geniuses take care of it please. T.I.A. \documentclass[12pt]{article} \usepackage[a4paper,margin=1in]{geometry} \usepackage{enumitem} \usepackage{amsmath} \begin{document} %======================== % First page %======================== \begin{center} {\Large \textbf{Sample Examination Paper}}\\[1em] {\large Mathematics}\\[2em] \end{center} \noindent \textbf{Candidate Name:} \rule{10cm}{0.4pt} \vspace{2em} \noindent \textbf{Instructions} \begin{enumerate}[leftmargin=2em] \item Write your name clearly in the space provided above. \item Answer \textbf{all five questions}. \item Write your answers in the spaces provided in this question paper. \item If you need additional space, use lined paper and attach it securely to this paper. \item You may use an HB pencil for graphs and diagrams. \item You should show all necessary working clearly. \item The total mark for this paper is \textbf{19}. \end{enumerate} \vfill \begin{center} \textit{Turn over for the first question} \end{center} \newpage %======================== % Questions %======================== \noindent \textbf{1.} Solve the equation \[ 3x - 7 = 11. \] \begin{flushright} [3] \end{flushright} \vspace{5cm} \noindent \textbf{2.} Expand and simplify \[ (x+2)(x-5). \] \begin{flushright} [4] \end{flushright} \vspace{5cm} \noindent \textbf{3.} A triangle has base $8$ cm and height $5$ cm. Calculate its area. \begin{flushright} [1] \end{flushright} \vspace{5cm} \noindent \textbf{4.} Differentiate \[ y = 4x^3 - 2x + 6. \] \begin{flushright} [5] \end{flushright} \vspace{5cm} \noindent \textbf{5.} The first three terms of a sequence are \[ 2,\ 5,\ 8,\ \dots \] Find the 10th term of the sequence. \begin{flushright} [6] \end{flushright} \vspace{5cm} \end{document} As you can see there. It is still a manual writing "19". so there, perhaps how to create command such as \mark. so it would print 19 by itself, because the LaTeX does the maths automatically. And if it exceeds 19, then print WARNING: TOTAL MARKS EXCEED 19.
- unicode-math font selection conflict with luatexja-fontspec only with ltx-talk?by Explorer on March 11, 2026 at 4:40 pm
The question arised from my answer here.Noted that has not yet mentioned explictly in the manual, ltx-talk use built-in math font support via lua-unicode-math as Joseph commented here. Let's consider the following cases: Original MWE: with ltx-talk(fontspec+lua-unicode-math)+luatexja-fontspec: \DocumentMetadata{} \documentclass{ltx-talk} % \usepackage{fontspec,lua-unicode-math} \setmathfont{STIX Two Math} \usepackage{luatexja-fontspec} \setmainjfont{FandolSong} \begin{document} 你好你好你好 $\nabla_{\mathcal{M}} f(x) + \int x^2 \mathrm{d}x+ \ell^1$. \end{document} Equivalent Case: The caseA is equivalent to use lua-unicode-math directly: \documentclass{article} \usepackage{fontspec,lua-unicode-math} \setmathfont{STIX Two Math} \usepackage{luatexja-fontspec} \setmainjfont{FandolSong} \begin{document} 你好你好你好 $\nabla_{\mathcal{M}} f(x) + \int x^2 \mathrm{d}x+ \ell^1$. \end{document} both gives: with the complaint: Missing character: There is no ∇ (U+2207) in font name:FandolSong:mode=node;s cript=hani;language=dflt;-kern;jfm=ujis! Missing character: There is no ℓ (U+2113) in font name:FandolSong:mode=node;s cript=hani;language=dflt;-kern;jfm=ujis! ... Missing character: There is no ? (U+2207) in font name:FandolSong:mode=node;sc Missing character: There is no ? (U+2207) in font name:FandolSong:mode=node;script=hani;language=dflt;-kern;jfm=ujis! Missing character: There is no ? (U+2113) in font name:FandolSong:mode=node;sc Missing character: There is no ? (U+2113) in font name:FandolSong:mode=node;script=hani;language=dflt;-kern;jfm=ujis! I try to pass no-math to luatexja-fontspec as manual(page.11) shows: \documentclass{article} \usepackage{fontspec,lua-unicode-math} \setmathfont{STIX Two Math} \usepackage[no-math]{luatexja-fontspec} \setmainjfont{FandolSong} \begin{document} 你好你好你好 $\nabla_{\mathcal{M}} f(x) + \int x^2 \mathrm{d}x+ \ell^1$. \end{document} But it doesn't work: There are two workaround/compared cases below: Case: A workaound with ltx-talk + ctex with ctex instead of luatexja-fontspec as I used in my previous answer: \DocumentMetadata{} \documentclass{ltx-talk} % \usepackage{fontspec,lua-unicode-math} \setmathfont{STIX Two Math} \usepackage[fontset=fandol]{ctex} \begin{document} 你好你好你好 $\nabla_{\mathcal{M}} f(x) + \int x^2 \mathrm{d}x+ \ell^1$. \end{document} behaves good: Case: article+unicode-math+luatexja-fontspec compared with the "Equivalent Case" luatexja-fontspec works with unicode-math but not lua-unicode-math: \documentclass{article} \usepackage{unicode-math} \setmathfont{STIX Two Math} \usepackage{luatexja-fontspec} \setmainjfont{FandolSong} \begin{document} 你好你好你好 $\nabla_{\mathcal{M}} f(x) + \int x^2 \mathrm{d}x+ \ell^1$. \end{document} The comparsion shows that luatexja-fontspec, without any math configuration, compatible with unicode-math but not lua-unicode-math, which is loaded by ltx-talk. I wonder why cause that, and any solution?
- how to compile Chinese in ltx-talk by Luatex?the Chinese characters can not be shown in Slideby WPP on March 11, 2026 at 12:54 pm
how to compile Chinese in ltx-talk by Luatex? \DocumentMetadata{} \documentclass{ltx-talk} % --- FONT SETTINGS --- % No need to load fontspec or unicode-math; ltx-talk already did. \setmainfont{Times New Roman} % Use STIX Two Math to match the "Times" look for your equations \setmathfont{STIX Two Math} \usepackage{luatexja-fontspec} \setmainjfont{times new roman} \begin{document} \begin{frame}{Sparse Recovery} 李白李白李白李白李白李白 \begin{itemize} \item \textbf{Riemannian Gradient:} $\nabla_{\mathcal{M}} f(x)$. \item \textbf{Sparsity:} Utilizing the $\ell^1$ norm for signal recovery. \end{itemize} \end{frame} \end{document}
- make4ht: mwe with align fails in texlive 2026by cmhughes on March 11, 2026 at 8:24 am
The following mwe does not compile using make4ht in texlive 2026 mwe \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} 1 & 2\\ 3 & 4 \end{align*} \end{document} call make4ht mwe question What configuration options do I need to adjust to make this compile?
- Need help writing this linear program! [closed]by Andrés Ingram on March 11, 2026 at 8:13 am
I need help writing the previous linear program on Overleaf, I'm struggling to align the constraints and the objective function as well. Claude and ChatGPT are not good help.
- How do I make all my tabular cells be vertically centered?by Draconis on March 11, 2026 at 4:08 am
I'm working on a document that contains quite a lot of tables. In many of these tables, some columns have normal text, while other columns have other things (e.g. inline images, math formulae, etc) that are taller than a normal line of text. With a normal tabular environment, the text ends up on the same baseline as the larger things, which doesn't look good. I would prefer it be vertically centered, so that the midline of the text lines up with the midline of the larger things. I've seen the tabularray package suggested, but it looks like that uses a very different syntax from a normal tabular, and I have many tables to update and a deadline in two days. I'm open to switching if there's a straightforward way to convert tabulars into tabularrays without changing anything about the default appearance or behavior, but otherwise, I'm worried about the dimensions changing. So: is there some way to change the behavior of a tabular (a certain table, a certain column, even a certain cell if necessary) so that text in cells is vertically centered, without changing anything else about its dimensions and layout? MWE: \documentclass[12pt,letterpaper]{book} \usepackage{booktabs} \begin{document} \begin{table}[h] \centering \begin{tabular}{ccc} \toprule Normal & Bigger & Normal \\ \midrule Lorem & {\Huge XYZ} & Ipsum \\ \midrule Dolor & {\Huge ABC} & Sit \\ \midrule Consec & {\Huge JKL} & Tetur \\ \bottomrule \end{tabular} \end{table} \end{document} I would like the midline of the smaller text to line up with the midline of the huge text, while keeping everything else about the table the same. I've seen many questions about vertically centering text in table columns, but none of the answers I've seen allow keeping the rest of the table the same (they tend to involve switching to a different environment with different behavior). I've seen that a single-cell multicolumn will center things vertically, but adding those to every single cell in many separate tables is going to be a nightmare, so I'd prefer something I can use once per table instead of once per cell if possible.
- Inline formula baseline issues of `a` with TeX Gyre Pagella Math?by Explorer on March 11, 2026 at 3:33 am
Here below is the example code: \documentclass{article} \usepackage{unicode-math} \setmathfont{TeX Gyre Pagella Math} \begin{document} Inline $(\frac{1}{b} , \frac{1}{a})$ \[ (\frac{1}{b} , \frac{1}{a})\] \end{document} Noted that the baseline of a is abnormal when inline, but normal in display. Is that a bug or feature of TeX Gyre Pagella Math? That is also quite confusing for me that why inline and display behave quite different, is not the same a glyph was used? Any hot-fix to change the baseline in inline math for a here? Any tricks(maybe luatex?) are all welcome!
- How to color background of breaking comments in lstlistings?by BadAtLaTeX on March 10, 2026 at 1:55 pm
In an lstlistings diff language style (see Highlighting a .diff file, Is there a ready solution to typeset a diff file?) I came across a problem with colored background using colorbox and breaklines=true (see lstlisting line wrapping). A mentioned package lstlinebgrd (see docs) did not work (https://tex.stackexchange.com/a/50263). It appears like this (see MWE below) Thus the question: How can I get line-breakable background color in lstlistings? Also, I was unable to apply any of these solutions: Background color of breakable box with thin blank lines Listing with background color not line breaking correctly Background color of breakable box with thin blank lines MWE % https://tex.stackexchange.com/a/106129 \documentclass{article} \usepackage[svgnames]{xcolor} \usepackage{listings} % \usepackage{lstlinebgrd} % \lstset{linebackgroundcolor={\color{green}}} % works % https://tex.stackexchange.com/a/372619 \newcommand{\lstbg}[3][0pt]{{\fboxsep#1\colorbox{#2}{\strut #3}}} % https://tex.stackexchange.com/a/50263 % https://tex.stackexchange.com/a/372619 \lstdefinelanguage{diff}{ basicstyle=\ttfamily\small, morecomment=[l][\color{gray}]{diff}, morecomment=*[f][\lstbg{red!20}][0]-, morecomment=*[f][\lstbg{green!20}][0]+, % morecomment=*[f][linebackground={\color{green}}][0]+, % doesn't work }[comments] \begin{document} \begin{minipage}{5cm} \begin{lstlisting}[ frame = single, language=diff, breaklines=true, postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space}, % https://tex.stackexchange.com/questions/116534/lstlisting-line-wrapping ] diff test content + small - small a very very very very very long line that will have to break + a new very very very very very long line that will have to break - replaced by another very very long line that wants to linebreak yet another very very long line that wants to linebreak end \end{lstlisting} \end{minipage} \end{document}
- luadraw in footerby PHL on March 10, 2026 at 12:01 pm
When trying to put a luadraw environment in a footer I obtain the following error Argument of \luacode@grab@lines has an extra }. Is there any workaround? If needed, I can consider using \AddToHookNext{shipout/background} (but this is not working either). This is really related to luadraw, as replacing the luadraw code by the TikZ code compiles without problems. %!TEX TS-program = lualatex \documentclass{article} \usepackage{luadraw} \usepackage{fancyhdr} \pagestyle{fancy} % This does not work %\cfoot{% % \begin{luadraw}{} % local g = graph:new{window={0,1,0,1},margin={0,0,0,0}, bbox = false} % local L = { Z(0,0), Z(1,1) } % g:Dpolyline(L,true) % g:Show() % \end{luadraw} %} % But this works % This is the TikZ code produced by the above luadraw picture \cfoot{% \begin{tikzpicture}[line join=round]% \begin{scope}% \draw[] (0,0) -- (1,1)--cycle;% \end{scope}% \end{tikzpicture}% } \begin{document} bla blo bli \end{document} Edit. If possible I would like a solution where the luadraw environment is really executed at each page and can use \thepage as a parameter.
- Access TeX counter inside luadrawby PHL on March 10, 2026 at 11:39 am
I am toying with luadraw and would like to have my graphic depending on \thepage for the number of iterations. I tried \\thepage, "\\thepage" or to use g:Writeln or tex.sprint but none of them worked. Minimal non-working example (inspired by the luadraw manual): %!TEX TS-program = lualatex \documentclass{article} \usepackage{luadraw} \begin{document} bla blo bli \begin{luadraw}{name=Sierpinski} local iteration = g:Writeln("\\thepage") %num? tex.sprint? local g = graph:new{window={-5,5,-5,5},margin={0,0,0,0},size={1,1}} local i = cpx.I local rand = math.random local A, B, C = 5*i, -5-5*i, 5-5*i -- triangle initial local T, niv = {{A,B,C}}, iteration for k = 1, niv do T = concat( hom(T,0.5,A), hom(T,0.5,B), hom(T,0.5,C) ) end for _,cp in ipairs(T) do g:Filloptions("full", rgb(rand(),rand(),rand())) g:Dpolyline(cp,true, "line width=0pt") end g:Show() \end{luadraw} \end{document}
- Why do none of these do anything? end document hooks and table of contentsby Bob on March 10, 2026 at 4:13 am
I cannot seem to figure out why the \clearpage (or anything for that matter) causes the \AtEndDocument hooks to not work. The other two dont seem to ever do anything which likely means I am using them wrong. \documentclass{article} \usepackage{atveryend} \AtEndDocument{\addtocontents{toc}{\protect bla?}} \AfterLastShipout{\addtocontents{toc}{\protect bla??}} \AtVeryEndDocument{\addtocontents{toc}{\protect bla???}} \begin{document} \tableofcontents \section{blub} \clearpage \LogHook{enddocument} \end{document} The output from the log is the same regardless of the \clearpage > Document-level (top-level) code (executed last): > -> \addtocontents {toc}{\protect bla?} Edit: Added photo demonstrating how none of the hooks function as expected.
- Fail to produce an octagon by repeating -- ([turn]45:{sqrt(2)}) 8 times with foreach [duplicate]by D G on March 9, 2026 at 3:58 pm
The expected output is shown in the first two. \documentclass[tikz,border=1cm]{standalone} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \draw (0,0) foreach \a in {0,1,...,6}{-- ++({45*\a}:{sqrt(2)})} -- cycle; \end{tikzpicture} \begin{tikzpicture} \draw (0,0) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- ([turn]45:{sqrt(2)}) -- cycle; \end{tikzpicture} \begin{tikzpicture} \draw (0,0) foreach \i in {0,...,6} {-- ([turn]45:{sqrt(2)})} -- cycle; \end{tikzpicture} \end{document} Why doesn't the last one produce the expected output?
- Is there some hooks when text style and color change?by Jinwen on March 9, 2026 at 1:54 pm
In this solution, Max Chernoff proposed a LuaTeX approach for customizing the hyphen character. However, it does so by replacing the hyphen char with the content given inside some predefined boxes. The content is thus fixed, not sensitive to changes in font, text style or text color. With the hook selectfont, one may reset these boxes each time the font got changed, as Max did in his answer. Is there some similar tricks that work for text style (such as \textbf, \emph) and text color (produced by \color or \textcolor)? (For instance, in the example below, it is expected to have green, italic shaped dashes.) Below is a MWE. \documentclass[landscape]{article} \usepackage{xcolor} %%%%%%%%%%%%%%%%%%%%%% %%% Implementation %%% %%%%%%%%%%%%%%%%%%%%%% %% Define the box to hold the hyphen replacement \makeatletter \newbox\example@tex@hyphen@box \newbox\example@manual@hyphen@box \AddToHook{selectfont}[auto-hyphen-box]{% %% Hyphen inserted by TeX \sbox{\example@tex@hyphen@box}{\textcolor{red}{-}}% %% Hyphen inserted manually \sbox{\example@manual@hyphen@box}{-}% }% \makeatother %% Define the Lua callback to replace hyphens with coloured versions \usepackage{luacode} \begin{luacode*} local disc_subtypes = table.swapped(node.subtypes("disc")) -- Get the box register numbers local pre_box = luatexbase.registernumber("example@tex@hyphen@box") local replace_box = luatexbase.registernumber("example@manual@hyphen@box") -- Replace the inserted hyphen nodes. luatexbase.add_to_callback("hyphenate", function(head, tail) node.hyphenating(head, tail) for n in node.traverse_id(node.id("disc"), head) do if (n.prev or {}).char == utf8.codepoint("-") then -- Probably an em- or en-dash, skip it goto continue end if n.subtype == disc_subtypes.automatic then n.pre = node.copy(tex.box[replace_box]) n.replace = node.copy(tex.box[replace_box]) else n.pre = node.copy(tex.box[pre_box]) end ::continue:: end end, "colour_hyphens") \end{luacode*} %%%%%%%%%%%%%%%%%%%%% %%% Demonstration %%% %%%%%%%%%%%%%%%%%%%%% \usepackage{fontspec} \setmainfont{TeX Gyre Pagella} \setsansfont{TeX Gyre Chorus} \newcommand{\SampleText}{% This is some-text with a-lot of hyphenated words-to demonstrate how-the discretionary hyphens-are coloured. En--dash em---dash.% } \newcommand{\SampleBox}[2]{% \parbox[t]{#1}{% #2\textcolor{green}{\emph{\SampleText}} }% } \pagestyle{empty} \setlength{\parindent}{0pt} \begin{document} \begin{tabular}{*5c} \SampleBox{5cm}{\rmfamily} & \SampleBox{5cm}{\sffamily} & \SampleBox{2cm}{\rmfamily} & \SampleBox{2cm}{\sffamily} & \SampleBox{1cm}{\rmfamily} \end{tabular} \end{document} NEWLY ADDED MWE: \documentclass{article} \usepackage{newpxtext} \usepackage{xcolor} % https://tex.stackexchange.com/a/759212 \makeatletter \newbox\example@tex@hyphen@box \newbox\example@manual@hyphen@box \AddToHook{selectfont}[auto-hyphen-box]{% %% Hyphen inserted by TeX \sbox{\example@tex@hyphen@box}{\textcolor{.!39}{-}}% %% Hyphen inserted manually \setbox\example@manual@hyphen@box=\hbox{-}% }% \makeatother \RequirePackage { luacode } \begin{luacode*} local disc_subtypes = table.swapped(node.subtypes("disc")) -- Get the box register numbers local pre_box = luatexbase.registernumber("example@tex@hyphen@box") local replace_box = luatexbase.registernumber("example@manual@hyphen@box") -- Replace the inserted hyphen nodes. luatexbase.add_to_callback("hyphenate", function(head, tail) node.hyphenating(head, tail) for n in node.traverse_id(node.id("disc"), head) do if (n.prev or {}).char == utf8.codepoint("-") then -- Probably an em- or en-dash, skip it goto continue end if n.subtype == disc_subtypes.automatic then n.pre = node.copy(tex.box[replace_box]) n.replace = node.copy(tex.box[replace_box]) else n.pre = node.copy(tex.box[pre_box]) end ::continue:: end end, "colour_hyphens") \end{luacode*} \begin{document} \textcolor{.!50}{word-with-hyphen} {\color{.!50} word-with-hyphen} \textbf{word-with-hyphen} \emph{word-with-hyphen} \end{document}
- Porting aligncolsatbottom.sty to TeX Live 2022+by ke. on March 9, 2026 at 1:22 pm
I'm using this template to produce posters with columns that are aligned at the bottom. It seems to be based on this solution by Chris Le Sueur. My problem is that it works with Tex Live 2021, but not with 2022 and up. Here is a minimal example: simple-poster.tex \documentclass[a0paper,portrait,margin=0pt, colspace=24pt,subcolspace=0pt,blockverticalspace=36pt,innermargin=50pt]{tikzposter} \usepackage{lipsum} % Random Text \usepackage[colalign]{aligncolsatbottom} %To align columns at bottom (!! please run 2 times) \title{The Best Title Ever} \author{First Author\textsuperscript{1}, \underline{Presenting Author}\textsuperscript{1,2}, Second Author\textsuperscript{2}} \institute{ \textsuperscript{1}Your primary affiliation, City, Country.\\ \textsuperscript{2}Another affiliation, City, Country.} %.............................................................................................................................................................................................. \begin{document} % % % HEAD % %.................................................................................... % % Title % \maketitle[width=0.96\linewidth,titletoblockverticalspace=36pt,linewidth=0,roundedcorners=10] %.............................................................................................................................................................................................. % % LEFT COLUMN % \begin{columns} \column{0.5} %.................................................................................... % % Block % \block[titleleft,roundedcorners=16]{Introduction}{ \raggedright \lipsum[4] } %.............................................................................................................................................................................................. % % RIGHT COLUMN % \column{0.5} %.................................................................................... % % Block % \block[titleleft,roundedcorners=16]{Another Block}{ \raggedright \lipsum[13] } \end{columns} \end{document} aligncolsatbottom.sty \usepackage{letltxmacro} \usepackage{ifthen} \newif\ifmy@colalign \my@colalignfalse \DeclareOption{colalign}{ \my@colaligntrue } \ProcessOptions\relax \ifmy@colalign % Align the bottoms of columns % Declarations \newcounter{my@column} \newcounter{my@column@loop} \newcounter{my@block} \newdimen\my@columnextraspace \newdimen\my@maxcolheight \newdimen\my@colheight \newdimen\my@blocktopstart \newdimen\my@rounded % Store the natural height and number of blocks of the current column in the aux file \gdef\my@storecolheight{ \ifnum\value{my@column} > 0 % \expandafter\newdimen\csname my@colheight\alph{my@column}\endcsname \expandafter\setlength\csname my@colheight\alph{my@column}\endcsname{\my@colheight} \immediate\write\@auxout{\noexpand\newlabel{my@colheight\alph{my@column}}{{\the\my@colheight}{}}} \immediate\write\@auxout{\noexpand\newlabel{my@numblocks\alph{my@column}}{{\the\c@my@block}}} \fi } \LetLtxMacro{\orig@block}{\block} % Replace the \block command with a version that pads each block by \my@columnextraspace \renewcommand{\block}[3][]{% \ifTP@columnEnvironment \my@blocktopstart=0pt\relax \advance\my@blocktopstart-\TP@blocktop \fi \orig@block[{#1}]{#2}{\vspace*{-0.5\my@columnextraspace}#3\vspace*{-0.5\my@columnextraspace}} \ifTP@columnEnvironment % count number of blocks \stepcounter{my@block} % keep track of the height of the current column \advance\my@blocktopstart\TP@blocktop \advance\my@colheight\my@blocktopstart % don't add the padding to the height \advance\my@colheight-\my@columnextraspace \fi } % Store the maximum natural height of any column in the aux file \gdef\my@storemaxcolheight{ \ifnum\value{my@column} > 0 % \newdimen\my@maxcolheight \newdimen\my@colheight@loop \setcounter{my@column@loop}{0} \loop\ifnum\value{my@column@loop}<\value{my@column} \stepcounter{my@column@loop} \my@colheight@loop\csname my@colheight\alph{my@column@loop}\endcsname \ifnum\my@colheight@loop<\my@maxcolheight \my@maxcolheight\my@colheight@loop \fi \repeat \immediate\write\@auxout{\noexpand\newlabel{my@maxcolheight}{{\the\my@maxcolheight}{}}} \fi } % Read the column height information and calculate how much extra space the current column needs per block \gdef\my@calcextraspace{ \@ifundefined{r@my@maxcolheight}{% \my@columnextraspace=0pt\relax }{% \expandafter\my@maxcolheight\ref{my@maxcolheight} \expandafter\my@colheight\ref{my@colheight\alph{my@column}} \setcounter{my@block}{\ref{my@numblocks\alph{my@column}}} \my@columnextraspace\my@maxcolheight \advance\my@columnextraspace-\my@colheight \divide\my@columnextraspace by \value{my@block} } } % Replace \column command by a version which stores the height (of the previous column) and calls \my@calcextraspace \gdef\column#1{ % #1: relative width \ifTP@columnEnvironment \my@storecolheight \stepcounter{my@column} \my@calcextraspace \setcounter{my@block}{0} \my@blocktopstart0pt \my@colheight0pt % Now the normal \column command \normalsize \setlength{\TP@blocktop}{\TP@coltop} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\TP@colspace} \setlength{\colwidth}{#1\TP@visibletextwidth+#1\TP@colspace-\TP@colspace-\blocklinewidth} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\blocklinewidth} \fi } % Replace the columns environment with a version which stores the height of the final column and the max column \renewenvironment{columns}{ \TP@columnEnvironmenttrue \setlength{\TP@colcenter}{-0.5\TP@visibletextwidth-\TP@colspace-0.5\blocklinewidth} \global\TP@colcenter=\TP@colcenter \global\TP@coltop=\TP@blocktop \global\TP@colbottom=\TP@blocktop \colwidth=0pt }{ \my@storecolheight \my@storemaxcolheight \TP@columnEnvironmentfalse \global\TP@blocktop=\TP@colbottom } \fi With TeX Live 2021, this works and aligns the columns. With TeX Live 2022 and up, on the second run of pdflatex, I get this error: ! Missing number, treated as zero. <to be read again> \xparse function is not expandable l.29 \column{0.5} I don't understand what this means, but maybe something in the redefinition of \column in aligncolsatbottom.sty needs to be adjusted? I quote it here: % Replace \column command by a version which stores the height (of the previous column) and calls \my@calcextraspace \gdef\column#1{ % #1: relative width \ifTP@columnEnvironment \my@storecolheight \stepcounter{my@column} \my@calcextraspace \setcounter{my@block}{0} \my@blocktopstart0pt \my@colheight0pt % Now the normal \column command \normalsize \setlength{\TP@blocktop}{\TP@coltop} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\TP@colspace} \setlength{\colwidth}{#1\TP@visibletextwidth+#1\TP@colspace-\TP@colspace-\blocklinewidth} \setlength{\TP@colcenter}{\TP@colcenter+0.5\colwidth+\blocklinewidth} \fi } If I comment out this part: \my@storecolheight \stepcounter{my@column} \my@calcextraspace \setcounter{my@block}{0} \my@blocktopstart0pt \my@colheight0pt then it compiles - but doesn't align the columns, obviously.
- How to depict an organic salt in chemfigby Chemguy on March 9, 2026 at 7:00 am
I'm trying to display a reaction with chemfig including salt of a a very complex organic anion. So far, I managed to create the structure of the anion and put it into a \figure enviroment, just to have it displayed. edit: Now with compiling code \documentclass[oneside]{scrreprt} \usepackage{graphicx} \usepackage{amsmath} \usepackage[subdued]{mathastext} \Mathastext[chem] \usepackage{chemfig} \let\chmf\chemfig \renewcommand*{\chemfig}[1]{{\MTVersion{chem}\tiny \chmf{#1}}} \setchemfig{atom sep=1.9em} %\UseTblrLibrary{booktabs} \usepackage[style=chem-angew]{biblatex} \begin{document} \newcommand{\mcfminus}{\scriptstyle{-}} \newcommand{\mcfright}[2]{#1^{#2}} \begin{figure} \chemfig{3 K^{+}} \chemleft{[} \chemfig{N ~[:270] -[:270]\mcfright{N} -[:270] =_[:330]N -[:270] -[:210]N -[:270] ( -[:330]N =^[:30] ( -[:330]\mcfright{N} -[:330] ~[:330]N ) -[:90]N =^[:150] ) =_[:210]N -[:150] ( -[:210]\mcfright{N} -[:210] ~[:210]N ) =_[:90]N -[:30] ( -[:330]\phantom{N} ) =_[:90]N ( -[:30] )} \chemright{]^{\text{3-}}} \end{figure} \end{document} I want to add the cation (3 K^{+}) before the brackets, at the height of the middle of the Anion, as it is usual with salts in chemistry (and further use is between \schemestart ans \schemestop) Can anyone help me how to do this? Current result:
- Producing an Elliptical Ring of Imagesby DDS on March 8, 2026 at 8:34 pm
Consider the code: \documentclass{book} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \thispagestyle{empty} \begin{center} \begin{tikzpicture} \fill[red] rectangle (8,6); \foreach \k in {0,30,...,360} \node at ($(4,3)+(\k:2)$) {\includegraphics[width=1.7em]{example-image-a}}; \end{tikzpicture} \end{center} \end{document} which produces: QUESTION: How may I modify this code in order produce an ellipse (instead of circle) of images? Thank you.
- How to correct for LaTeX and/or package changes affecting parsing of text in TikZ decoration for TL2020 vs TL2021 vs TL2022/3 vs TL2024 vs TL2025/6?by cfr on March 8, 2026 at 7:31 pm
Consider the following code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{% decorations.text,% mindmap,% } \begin{document} \begin{tikzpicture} \path[ adddecrev/.style={% postaction={decorate, decoration={text along path, text={##1}, raise=3pt, }}}, small mindmap, ] node (norm) [root concept, concept, adddecrev={AAA AAA|\hskip 7.5pt| ||AAAAA AAA{\kern10ptA}A AA AA}] {AAAAAAAAA} [counterclockwise from=120] % removing this child eliminates the warnings child { node [concept, adddecrev={X{\kern-2ptX}{\kern-1ptX}{\kern4ptX}{\kern0ptX}X|\hskip8pt| ||X{\kern-2ptX}X{\kern-1ptX}{\kern-1ptX} X{\kern-3ptX}{\kern-1ptX}l{\kern-1ptX}|\hskip-2pt|X||{\kern-1ptX}|\hskip4pt|X||{\kern-2ptX}|\hskip-2pt|X|| }] {MMMMMMMM} } ; \end{tikzpicture} \end{document} In TL2020, this compiles without complaint for either pdfLaTeX or LuaLaTeX. In TL2025 or 2026, it complains Missing character: There is no A in font nullfont! In TL2024, the complaint is Missing character: There is no @ in font nullfont! In TL2022 and TL2023, the complaint is Missing character: There is no ? in font nullfont! In TL2021, the complaint is Missing character: There is no > in font nullfont! What causes these differences? Usually the nullfont warnings relate directly to problematic characters in the source. The A suggests that might be the case, except that removing the X line makes the problem disappear. Moreover, for earlier installations, the characters complained of bear no obvious relation to the input and I'm not sure where they are coming from or what the problem is. I also can't see anything obviously wrong with the code specifying the text for the decoration, despite rereading the relevant part of the manual. What is happening here? Is my code erroneous? If so, how can I correct it? In any case, is there a way to avoid the problem with a current TeX Live?