• Exam class: change color of \firstpagefootrule, \firstpageheadrule and \runningheadrule \runningfootrule
    by MrI2C on March 31, 2026 at 7:53 pm

    is there a way to change the color end pts thickness from default black to anything else in the exam class? \runningheadrule % lijn onder de running header (pagina 2+) \runningfootrule % lijn boven de running footer (pagina 2+) \firstpageheadrule % lijn onder de header op pagina 1 \firstpagefootrule % lijn boven de footer op pagina 1 for example here: \documentclass[12pt, a4paper, addpoints]{exam} % ── Pakketten ────────────────────────────────────────────────────────────────── \usepackage[a4paper, top=3cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} %\usepackage{helvet} %\usepackage{palatino} % of met betere math-ondersteuning: %\usepackage{newpxtext} %\usepackage{newpxmath} \usepackage{xcolor} \usepackage{lipsum} \renewcommand{\familydefault}{\sfdefault} % ── Kleuren ──────────────────────────────────────────────────────────────────── \definecolor{darkblue}{RGB}{26,37,47} \definecolor{midgray}{RGB}{85,85,85} % ── exam class: activeer de vier regels ─────────────────────────────────────── \runningheadrule % lijn onder de running header (pagina 2+) \runningfootrule % lijn boven de running footer (pagina 2+) \firstpageheadrule % lijn onder de header op pagina 1 \firstpagefootrule % lijn boven de footer op pagina 1 % ── Running header/footer (pagina 2+) ───────────────────────────────────────── \runningheader {\textbf{Examen: Inleiding tot de Magie}} {} {\textcolor{midgray}{Academiejaar 2025--2026}} \runningfooter {\textcolor{midgray}{Faculteit Toveren \& Hocus Pocus \quad|\quad Vertrouwelijk}} {} {Pagina \thepage\ van \numpages} % ── First page header/footer (pagina 1) ─────────────────────────────────────── \firstpageheader {} {% \textbf{\large\textcolor{darkblue}{UNIVERSITEIT HOGWARDS}}\\[3pt] \textcolor{midgray}{Faculteit Magie \& Toveren}% } {} \firstpagefooter {Datum: 15 juni 2026 \quad|\quad Duur: 3 uur Gesloten boek} {} {Nummer: \underline{\hspace{4cm}}} % ══════════════════════════════════════════════════════════════════════════════ \begin{document} % ── Titel ───────────────────────────────────────────────────────────────────── \begin{center} {\LARGE\bfseries\textcolor{darkblue}{EXAMEN: INLEIDING TOT DE MAGIE}}\\[6pt] {\large\textcolor{midgray}{Bachelor Magicus -- 1ste jaar \quad|\quad 15 juni 2026}} \end{center} \vspace{1em} \textbf{Instructies} \lipsum[1] \lipsum[2] \lipsum[3] % ── Vragen ──────────────────────────────────────────────────────────────────── \begin{questions} \question[20] \lipsum[1] \end{questions} % ── Pagina 2: antwoordruimte ────────────────────────────────────────────────── \newpage \textbf{Antwoordruimte -- Vraag 1} \lipsum[4] \lipsum[5] \lipsum[1] \lipsum[2] \end{document}

  • I started using TeXstudio and my margins are crazy
    by Анна on March 31, 2026 at 5:54 pm

    I used to use overleaf for work, and my documents always looked fine, but when I moved the same code to the TeXstudio editor, no matter how I tried to change the preamble or adjust the program, my document's margins weren't respected. Here's my preamble: \documentclass[12pt,a4paper,titlepage]{article} \usepackage[utf8]{inputenc} \usepackage[T2A]{fontenc} \usepackage[russian, english]{babel} %\usepackage{multicol} \usepackage{float} \usepackage{pgfplots} \usepackage{booktabs} \usepackage{amsmath,amsthm,amssymb} \usepackage{mathtext} \usepackage{graphicx} \usepackage{hyperref} \usepackage{gensymb} \usepackage{array} \usepackage{mathrsfs} \usepackage[parfill]{parskip} \usepackage{showframe} \usepackage{hyperref} \usepackage[left=15mm, top=20mm, right=15mm, bottom=20mm, nohead, nofoot]{geometry} %\makecell[l]{$$ \\ $$ } для колонок Пример отображения: Буду рада любым предложениям по решениям этой проблемы.

  • Phantom overline over visible expression
    by Michael on March 31, 2026 at 4:22 pm

    The following code: \documentclass{article} \begin{document} \[ f(x',\overline{x'}) \] \end{document} produces the following output for me: I'm a bit bothered that the heights of the primes are mismatched. My first thought for how to fix this issue was to add a phantom overline over the first argument so that the prime in the first argument would get pushed down to the same height. However, despite some experimentation with syntax (\phantom{\overline}{x'} for instance), I couldn't find something which compiles. Apologies if this has been asked before. The inverted version of this question overline over no text does not seem relevant here.

  • mhchem: Replace placeholder in formula
    by cis on March 31, 2026 at 3:11 pm

    I have a large table with many cells of the type <appropriated value>c<Mendeleev's correction>; e.g., BeCl3cBeCl2, VCl2cVCl5,... I would like to display this in a special notation: Is the following an efficient implementation, or is there a better way? \newcommand{\mycorrectio}{\ensuremath{\,{\color{red}\scriptscriptstyle\complement}\,}} % \NewDocumentCommand{\AddCorrectio}{m}{% \saveexpandmode\expandarg \StrSubstitute{#1}{c}{{{\mycorrectio}}}[\temp]% \temp% \restoreexpandmode% } Does mhchem perhaps have its own method for making such substitutions? PS: I just noticed that mhchem no longer seems to work in the table. Oh dear... \documentclass{article} \usepackage[version=4]{mhchem} \usepackage{pgfplotstable} \pgfplotsset{compat=1.18} \usepackage{xstring} \usepackage{amsmath, amssymb} \usepackage{xcolor} \newcommand{\mycorrectio}{\ensuremath{\,{\color{red}\scriptscriptstyle\complement}\,}} % \NewDocumentCommand{\AddCorrectio}{m}{% \saveexpandmode\expandarg \StrSubstitute{#1}{c}{{{\mycorrectio}}}[\temp]% \temp% \restoreexpandmode% } \pgfplotstableset{ % Standard chemistry without substitution StandardMHchem/.style={% string type, column type={l}, postproc cell content/.code={ \pgfkeyssetvalue{/pgfplots/table/@cell content}{\ce{##1}} } },% % Chemistry with correction symbol MendeleevCorrectio/.style={ string type, column type={l}, postproc cell content/.code={ \edef\final{\noexpand\ce{\AddCorrectio{##1}}}% \pgfkeyslet{/pgfplots/table/@cell content}{\final}% } } } \pgfplotstableread[header=false]{ Cl BeCl3cBeCl2 VCl2cVCl5 - InCl2cInCl3 }\mydata \begin{document} \section{Mendeleev's Correctios} \subsection{Text} \AddCorrectio{BeCl3cBeCl2} \subsection{Table} \pgfplotstabletypeset[ display columns/0/.style={% StandardMHchem, column name={Standard \ce{mhchem}} },% % Create a virtual copy of column 0 for the correction view create on use/corr/.style={create col/copy=0}, columns={0, corr}, columns/corr/.style={MendeleevCorrectio, column name={With AddCorrectio}}, every head row/.style={after row=\hline}, ]{\mydata} \end{document}

  • Graph of f and f' with luacas package
    by Sebastiano on March 31, 2026 at 1:29 pm

    Recently I have discovered the interesting package named luacas (compilable with LuaLaTeX). To pag. 14 of the manual https://ctan.mirror.garr.it/mirrors/ctan/macros/luatex/latex/luacas/doc/luacas.pdf I have not understood the necessary packages to put in the preamble to compile the MWE to plot f and f'. Someone please, can help me? Here the fragment of the code: \directlua{ tex.print(h:tolatex()) } For Bob’s purposes, \fetch{h} is exactly what he needs: \begin{tikzpicture}[scale=0.9] \begin{axis}[legend pos = north west] \addplot [domain=-3.5:1.5,samples=100] {\fetch{h}}; \addlegendentry{$f$}; \addplot[densely dashed] [domain=-3.25:1.25,samples=100] {\fetch{dh}}; \addlegendentry{$df/dx$}; \addplot[gray,dashed,thick] [domain=-3.5:1.5] {0}; \end{axis} \end{tikzpicture} Alternatively, Bob could use \store. The \store command will fetch the contents of its mandatory argument and store it in a macro of the same name. \store{h} \store{dh}

  • Is there a lowercase Greek letter font with a fixed width in math format?
    by 2023 Siri on March 31, 2026 at 1:20 pm

    I've noticed that monospaced fonts have uppercase Greek letters but no lowercase Greek letters. Is there a mathematical format to resolve this issue with monospaced fonts? \documentclass{article} \begin{document} $\mathtt{\Gamma \Delta \Theta \Lambda \Xi \alpha \beta \gamma \delta}$ \end{document}

  • add image to footline only in beamer titleframe
    by Matteo on March 31, 2026 at 1:11 pm

    Hi I'm working on a beamer presentation and I already have a somewhat modified \titlepage and setting, to this I would ideally need to add an image to the footline; however, after a few experiments and editing the prompt I already worked on I cannot quite achieve what I want... The problem is for one that the image seems to overlay the original footline instead of being the only element there and is poorly cropped; additionally, the page numbers are not visible on the \titlepage although I set them up as before. Lastly, I wish to have a very small margin from the bottom, left, and right to don't show the image as it is completely framed to the bottom of the slide. Thanks! Below, a MWE \documentclass[xcolor=svgnames,aspectratio=149]{beamer} \usepackage{tikz} \usepackage[normalem]{ulem} \usepackage[dvipsnames]{xcolor} \usetheme{Singapore} \usecolortheme{dolphin} \usecolortheme[named=OliveGreen]{structure} \definecolor{floralwhite}{rgb}{1.0, 0.98, 0.94} \definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03} \definecolor{forestgreen(traditional)}{rgb}{0.0, 0.27, 0.13} \makeatletter \def\ps@navigation@titlepage{% \setbeamertemplate{footline}{ \leavevmode% \pgfsetfillopacity{.85}\centering\includegraphics[width=\paperwidth,height=.219in]{example-image-golden} \vskip-1pt \hbox{% \begin{beamercolorbox}[wd=.333333\paperwidth,ht=3.1ex,dp=1.125ex,center]{author in head/foot}% \end{beamercolorbox}% \begin{beamercolorbox}[wd=.333333\paperwidth,ht=3.1ex,dp=1.125ex,center]{title in head/foot}% \end{beamercolorbox}% \begin{beamercolorbox}[wd=.333333\paperwidth,ht=3.1ex,dp=1.125ex]{date in head/foot}\hspace{15em}\insertframenumber\,/\,\inserttotalframenumber \end{beamercolorbox} }% \vskip0pt% } \@nameuse{ps@navigation}} \addtobeamertemplate{title page}{\thispagestyle{navigation@titlepage}}{} \makeatother \makeatletter \setbeamertemplate{footline}{ \leavevmode% \begin{beamercolorbox}[wd=.3333\paperwidth,ht=3.1ex,dp=1.125ex,center]{author in head/foot}\insertshortauthor% \end{beamercolorbox}% \begin{beamercolorbox}[wd=.3333\paperwidth,ht=3.1ex,dp=1.125ex,center]{title in head/foot}\insertshorttitle% \end{beamercolorbox}% \begin{beamercolorbox}[wd=.3333\paperwidth,ht=3.1ex,dp=1.125ex,center]{date in head/foot}\insertshortdate{}\hspace{5em}\insertframenumber\,/\,\inserttotalframenumber \end{beamercolorbox}% }% \makeatother \title[Conference XYZ]{Project's Title} \author[INIT.]{\footnotesize \texorpdfstring{\uline{auth1}}{} \and auth2 \and auth3 \and etc.} \date{\vspace*{-.4in}\today} \titlegraphic{% \begin{tikzpicture}[overlay,remember picture] \node[at=(current page.north west), anchor=north west] {% \hspace{2em} \includegraphics[width=.75in,keepaspectratio]{example-image-a} \hspace{3.75em} \includegraphics[width=.75in,keepaspectratio]{example-image-b} \hspace{3.75em} \includegraphics[width=.75in,keepaspectratio]{example-image-c} \hspace{3.75em} \includegraphics[width=.75in,keepaspectratio]{example-image} }; \end{tikzpicture} } \setbeamercolor{title}{fg=black} \setbeamercolor{titlelike}{parent=structure} \setbeamerfont{title}{shape=\bfseries,size=\Huge,family=\fontfamily{cmr}\selectfont} \setbeamercolor{author in head/foot}{fg=floralwhite,bg=DarkGreen!50!white} \setbeamercolor{title in head/foot}{fg=floralwhite!75,bg=DarkGreen!75!white} \setbeamercolor{date in head/foot}{fg=floralwhite!50,bg=DarkGreen} \begin{document} {\setbeamertemplate{headline}[plain] \setbeamertemplate{navigation symbols}{} \begin{frame} \vspace{.2in} \titlepage \end{frame} } \begin{frame} \end{frame} \end{document} Actual output: EDIT sketch of the output

  • Hyperlink does not scale in pgfplots
    by Thomas on March 31, 2026 at 10:32 am

    I have a figure drawn with pgfplots where I cite a reference in the legend. the issue I have is when I try to scale the whole figure, I noticed that the green hyper link for the reference is not scaled and inserted at the original place. Here is an ECM with on the one hand the figure in whole size, and on the other hand the figure scaled. \documentclass{article} \usepackage{biblatex} \usepackage{hyperref} \usepackage{pgfplots} \pgfplotsset{compat=1.5} \addbibresource{biblatex-examples.bib} \begin{document} \begin{tikzpicture} \begin{axis} \addplot[red, domain=-3e-3:3e-3, samples=51]{exp(-x^2 / (2e-3^2)) / (1e-3 * sqrt(2*pi))}; \addlegendentry{Text \cite{aksin}} \end{axis} \end{tikzpicture} % \begin{tikzpicture}[scale=0.9] \begin{axis} \addplot[red, domain=-3e-3:3e-3, samples=51]{exp(-x^2 / (2e-3^2)) / (1e-3 * sqrt(2*pi))}; \addlegendentry{Text \cite{aksin}} \end{axis} \end{tikzpicture} \printbibliography \end{document} On the linked export, we see that the second green boxed is not over the reference [1], but over the place it would have been if the figure were not scaled. Is it possible to set the correct location for this box ?

  • Luadraw as a background image
    by PHL on March 31, 2026 at 7:43 am

    I would like to use a luadraw picture as a background image on a page. I tried overlay, but this is not working as the picture is shifted above right. Luadraw is not (yet?) on CTAN, but available on github: luadraw %!TEX TS-program = lualatex \documentclass[a4paper]{article} %\usepackage[ignoreall, margin=-0cm, marginparsep=0cm]{geometry} \usepackage{luadraw} \begin{document} \begin{luadraw}{} local g = graph:new{ margins={0,0,0,0} , size={31,31} , pictureoptions="overlay" } for j= 1, 5 do for k=1,10*j do g:Dcircle(Zp(j,k*math.pi/(5*j)),1) end end g:Show(true) \end{luadraw} % without overlay, the center of the picture (on a new page) is approximately at (20,10) (if (0,0) is the bottom left corner % with overlay, the center of the picture is out the page (at (30,50) ? maybe) \end{document} (The original picture is more complex than this one, so using a standard tikzpicture is not really an option)

  • How do I break a link within \url{} only after / or //?
    by Simon on March 30, 2026 at 10:15 pm

    I am required to break the links within \url{} to my references only after / or //, not after any other symbol that also might occur in a link. How do I implement this properly for all the links to my references at once? Have I just missed an option of the hyperref package or the \url{} command, or could an input to Forcing linebreaks in \url solve the problem? I have prepared a MWE to illustrate the problem: \documentclass{article} \usepackage[hidelinks]{hyperref} \begin{document} {\raggedright \begin{thebibliography}{} \bibitem[Reference 1]{reference1} Available at \url{https://tex.stackexchange.com/one/two-three/four_five_six} \bibitem[Reference 2]{reference2} Available at \url{https://tex.stackexchange.com/seven-eight-nine/ten_eleven/twelve} \end{thebibliography} } \end{document}

  • Exam overview using exercisepoints package: total and section-wise scores
    by Sebastiano on March 30, 2026 at 9:33 pm

    I have a "frontespizio" that I use for my exam for my students \documentclass[a4paper,12pt]{article} \usepackage[italian]{babel} \usepackage{mathtools,amssymb,siunitx} \usepackage[top=1.5cm,bottom=1.5cm,left=1.5cm,right=1.5cm,headsep=10pt,a4paper]{geometry} \usepackage{subcaption} \newcommand{\truefalse}{\hfill\framebox[1.25em][c]{V}\quad\framebox[1.25em][c]{F}} \newcommand{\squarecap}[1]{\fbox{\makebox[\height]{#1}}} \usepackage{enumext} \usepackage{enumitem} \begin{document} \begin{center} \textbf{I} \end{center} \begin{enumext}[label=\textbf{Domanda} \arabic*.,wrap-label=\textbf{#1},list-indent=0pt, save-ans=test] \setenumext[keyans]{label=\Alph*,font=\small,nosep,wrap-label={\fbox{\makebox[\height]{##1}}}} \item Una motocicletta è lanciata lungo un rettilineo alla velocità costante di 50 m/s. Quanti minuti impiega per percorrere una distanza di 22 km? \begin{keyans}[columns=2,parsep=5pt] \item 6,1 min. \item 7,3 min. \item 7,0 min. \item 7,7 min. \end{keyans} \item Una bicicletta si muove con velocità costante. Se al tempo $t$ = 10 s la sua velocità è 15 m/s, quanto vale la velocità al tempo $t$ = 20 s? \begin{keyans}[columns=2,parsep=2pt] \item 10 m/s. \item 15 m/s. \item 20 m/s. \item 30 m/s. \end{keyans} \item Un’auto di Formula 1, partendo da ferma, impiega \qty{6.8}{\second} per raggiungere la velocità massima di \qty[per-mode=symbol]{270}{\kilo\meter\per\hour}. Qual è la sua accelerazione media? \begin{keyans}[columns=2,parsep=2pt] \item \qty[per-mode=symbol]{9.11}{\meter\per\second\squared}. \item \qty[per-mode=symbol]{39.71}{\meter\per\second\squared}. \item \qty[per-mode=symbol]{0.025}{\meter\per\second\squared}. \item \qty[per-mode=symbol]{11}{\meter\per\second\squared}. \end{keyans} \end{enumext} \begin{center} \textbf{II} \end{center} Giulia e Marco fanno una gara. Giulia si muove a una velocità costante di 3 m/s. Marco parte 10 m più avanti e si muove a una velocità costante di 2 m/s. Scrivi la legge oraria del moto di Giulia e del moto di Marco. A quale istante si incontreranno? \begin{center} \textbf{III} \end{center} Esso esprime il diagramma orario $t-x$ di un oggetto che si muove di moto rettilineo uniforme. Determina per gli intervalli di tempo da $0\div 2$ secondi, $2\div 4$ secondi, $6\div12$ secondi la sua velocità media. Si calcoli infine la velocità media complessiva e la relativa legge oraria nell'intervallo da 0 a 2 secondi. \end{document} an I would use the the package exercisepoints (in Italian language) to have a scores for test and exercises with a final table. Here a MWE with exercisepoints: \documentclass[a4paper,12pt]{article} \usepackage[italian]{babel} \usepackage{exercisepoints} \begin{document} \begin{exercise}[Simple Equation] Determine a number $x$ such that $3 \cdot x = 15$\points {1.5} and explain how you did that.\points{3} \end{exercise} \begin{exercise}[Calculus] \vspace{-1em} \begin{subexercise}[Derivatives] Determine the derivatives of the following functions. \begin{enumerate} \item $f\colon \mathbb{R} \to \mathbb{R}$, $f(x) = x^2+2x+3$ \itempoints{1} \item $g\colon \mathbb{R} \to \mathbb{R}$, $g(x) = \exp(x^2)$ \itempoints{3} \end{enumerate} \end{subexercise}\vspace{-1em} \begin{subexercise}[Maxima and Minima] Determine the local maximum or minimum of the function $f\colon \mathbb{R} \to \mathbb{R}, f(x) = x^2+2x+3$.\points{3} \end{subexercise} \end{exercise} Exercise 0 has \getpoints{0} points, there are \numberofexercises \ exercises with a total of \totalpoints \ points. \end{document}

  • Setting node style on specific slide, in a deferred manner
    by ysalmon on March 30, 2026 at 7:43 pm

    I want to animate a DFS in an example graph. I know I can use keys like onslide to activate specific styling on a given slide, but this requires to give the instruction at the place where the node is defined. I would like to be able to just specify the order in which DFS visits the nodes, eg. \foreach \val[count=\slide from 2] in {0,1,2,3,4,5,11,16,15,14,20,19,25,18,24,,31,30,,36,42,43,38,39,46,47,40,35,34,27} {set node l\val to be red-filled starting on slide \slide} I got the idea to use a expl3 proplist to store, on a given slide, which nodes should have which style (full code below). Then I can define a custom tikz style with some code to retrieve from the proplist and do a \pgfkeysalso. Presently, this works if I set the style to eg. fill. However, setting it to eg. fill=red gives an error Package pgfkeys Error: I do not know the key '/tikz/fill=red' and I am going to ignore it. Perhaps you misspelled it. I presume this is a catcode issue, but I am not able to solve it (I tried converting from tokenlist to expl3 string, to no avail). I know I can avoid the need for an = sign by defining a custom style with the appropriate colour (and this is better code style anyway). But still, this limitation is annoying. MWE : \documentclass{beamer} \usepackage{tikz} \ExplSyntaxOn \NewDocumentCommand{\DeferPropInit}{m} { \prop_gclear_new:c {__DeferPropList#1} } \NewDocumentCommand{\DeferPropReplace}{D<>{.-}mmm} { \only<#1>{\prop_gput:cee {__DeferPropList#2} {#3} {#4}} } % not used here, might be useful in other circumstances \NewDocumentCommand{\DeferPropAppend}{D<>{.-}mmm} { \only<#1>{\prop_get:ceNTF {__DeferPropList#2} {#3} \l_tmpa_tl {\prop_gput:cee {__DeferPropList#2} {#3} {\l_tmpa_tl, #4}} % #3 present in list {\prop_gput:cee {__DeferPropList#2} {#3} {#4}} % #3 not present in list } } \tikzset{DeferPropGet/.code~2~args = { \prop_get:ceNT {__DeferPropList#1} {#2} \l_tmpa_tl {\pgfkeysalso {\l_tmpa_tl}} }} % for debug \NewDocumentCommand{\DeferPropLog}{m}{\prop_log:c {__DeferPropList#1}} \ExplSyntaxOff \begin{document} \begin{frame} \begin{center} \begin{tikzpicture} \DeferPropInit{DFS} \foreach \val[count=\slide from 2] in {0,1,2,3,4,5,11,16,15,14,20,19,25,18,24,,31,30,,36,42,43,38,39,46,47,40,35,34,27} {\DeferPropReplace<\slide->{DFS}{l\val}{fill}} % breaks with {fill=red} %\DeferPropLog{DFS} % for debug \foreach \i in {0,...,5}{ \foreach \j in {0,...,7}{ \pgfmathtruncatemacro\eti{\i+\j*6} \draw(\j,-\i) node[DeferPropGet={DFS}{l\eti}] (l\eti) {\eti}; } } % graph edges omitted for brievety \end{tikzpicture} \end{center} \end{frame} \end{document}

  • keybindings for latex-workshop's recipes in dev container fail to work
    by D G on March 30, 2026 at 7:25 pm

    I am using dev container with the following configuration file devcontainer.json: { "image": "texlive/texlive:latest-minimal", "name": "LaTeX", "customizations": { "vscode": { "keybindings": [ { "key": "ctrl+shift+alt+b", "when": "editorTextFocus && resourceExtname == .tex", "command": "latex-workshop.recipes", "args": "texpng" } ], "extensions": [ "james-yu.latex-workshop" ], "settings": { "files.eol": "\n", "latex-workshop.latex.tools": [ { "name": "pdflatex", "command": "pdflatex", "args": [ "-interaction=nonstopmode", "%DOC%" ] }, { "name": "magick", "command": "magick", "args": [ "-density", "150", "%DOCFILE%.pdf", "-alpha", "remove", "%DOCFILE%-%d.png" ] } ], "latex-workshop.latex.recipes": [ { "name": "texpdf", "tools": [ "pdflatex" ] }, { "name": "texpng", "tools": [ "pdflatex", "magick" ] } ], "latex-workshop.latex.recipe.default": "texpdf" } } }, "postCreateCommand": "apt-get update && apt-get install -y imagemagick" } The minimal input file: \documentclass{article} \begin{document} Happy \LaTeX ing! \end{document} ctrl+shift+alt+b fails to invoke the recipe texpng. What am I missing here?

  • Using {align} to align text/working across multiple paragraphs [duplicate]
    by Nathan on March 30, 2026 at 1:36 pm

    How can I adjust this code such that the second half of this example will align with the top half at the = and [ ]? I need to have the 'Rearrange...' text remain in between. Thank you! 🙂 \begin{align*} y+3x &= 2 &[1] \\ y+8 &= 7x &[2] \end{align*} Rearrange equation [1] such that $y$ becomes the subject: \begin{align*} y+3x &= 2\\ y &= 2-3x &[1] \end{align*}

  • Problem with \textwidth wide subfigure array in JaCOW template (twocolumn environment)
    by WolfiG on March 30, 2026 at 1:28 pm

    The following LaTeX code: % % !BIB TS-program = biber % !BIB program = biber % !TeX spellcheck = en_US % !TeX program = lualatex % % support document for version: v 3.00 Feb 2026 Volker RW Schaa % % \documentclass[luatex]{jacow} \usepackage[english]{babel} \usepackage{subcaption} \usepackage{lipsum} \listfiles \begin{document} \title{My title} \author[1]{author 1} \author[1]{author 2} \affil[1]{affiliation 1} \maketitle \begin{abstract} The abstract should summarize the context, content and conclusions of the paper in less than 200 words. It should be written in the present tense and refer to the work described in the paper. The abstract should be self-contained, without abbreviations, footnotes, or references. It should be formatted as a single paragraph. \end{abstract} \section{Section I} \begin{figure}[htb] \centering \begin{minipage}{0.99\textwidth} \begin{subfigure}{0.49\textwidth}{\centering\includegraphics[width=\textwidth]{example-image-a}}\end{subfigure} \begin{subfigure}{0.49\textwidth}{\centering\includegraphics[width=\textwidth]{example-image-b}}\end{subfigure} \vfill \begin{subfigure}{0.49\textwidth}{\centering\includegraphics[width=\textwidth]{example-image-c}}\end{subfigure} \begin{subfigure}{0.49\textwidth}{\centering\includegraphics[width=\textwidth]{example-image-a}}\end{subfigure} \caption{Another caption.} \label{fig:HITRAP} \end{minipage} \end{figure} \lipsum[1-3] \end{document} Produces this output: Obviously, the text behind/in front of the figure is wrong. How can I make the text correctly surround the figure with the four subfigures and caption? If a solution does not use a minipage environment, this is fine with me.

  • Automate uncovering of an align in beamer with line numbers adapting
    by scottkosty on March 30, 2026 at 12:35 pm

    I'm currently using Automate *alert*-uncovering of lines of an align in beamer to uncover (and alert) lines of an align environment one line at a time. I'm also using An alt fill-in-the-blank with question in the middle to reveal some text on a subsequent overlay. When combining these two approaches, I want the line number to be shown on the first overlay that contains that line. Currently, it is revealed on the last overlay of that line. Here is my example code: \documentclass{beamer} \usepackage{mathtools} \usepackage{amstext} \usepackage{amsthm} \beamerdefaultoverlayspecification{<alert@+|+->} % https://tex.stackexchange.com/questions/661230/automate-alert-uncovering-of-lines-of-an-align-in-beamer % https://tex.stackexchange.com/questions/611375/automate-uncovering-of-lines-of-an-align-in-beamer \ExplSyntaxOn % mode should be \makeatother by default. % \makeatother \cs_new_eq:NN \_overlayalign_orig_align: \align \cs_new_eq:NN \end_overlayalign_orig_align: \endalign \exp_after:wN \cs_new_eq:NN \exp_after:wN \_overlayalign_orig_starred_align: \cs:w align* \cs_end: \cs_new_eq:NN \end_overlayalign_orig_starred_align: \endalign \seq_new:N \l__overlayalign_linesin_seq \seq_new:N \l__overlayalign_linesout_seq \seq_new:N \l__overlayalign_onelinein_seq \seq_new:N \l__overlayalign_onelineout_seq \cs_new:Npn \overlayalign_add_alert_to_cells:n #1 { \seq_set_split:Nnn \l__overlayalign_linesin_seq { \\ } { #1 } \seq_map_inline:Nn \l__overlayalign_linesin_seq { \seq_clear:N \l__overlayalign_onelineout_seq \seq_set_split:Nnn \l__overlayalign_onelinein_seq { & } { ##1 } \seq_map_indexed_inline:Nn \l__overlayalign_onelinein_seq { \int_compare:nNnTF { ####1 } = { 1 } { \seq_put_right:Nn \l__overlayalign_onelineout_seq { \action<+-|alert@+> { ####2 } } } { \seq_put_right:Nn \l__overlayalign_onelineout_seq { \action<.-|alert@.> { ####2 } } } } \seq_put_right:Nx \l__overlayalign_linesout_seq { \seq_use:Nnnn \l__overlayalign_onelineout_seq { & } { & } { & } } } } \newenvironment{overlayalign}{ \RenewDocumentEnvironment{align}{+b} { \exp_after:wN \cs_set_nopar:Npn \cs:w tagform@ \cs_end: ####1 { \cs:w maketag@@@ \cs_end: { \action<.-|alert@.> { ( \ignorespaces ####1 \unskip \cs:w @@italiccorr \cs_end: ) } } } \overlayalign_add_alert_to_cells:n { ##1 } \begin{_overlayalign_orig_align:} \seq_use:Nnnn \l__overlayalign_linesout_seq { \\ } { \\ } { \\ } \end{_overlayalign_orig_align:} } { } \RenewDocumentEnvironment{align*}{+b} { \overlayalign_add_alert_to_cells:n { ##1 } \begin{_overlayalign_orig_starred_align:} \seq_use:Nnnn \l__overlayalign_linesout_seq { \\ } { \\ } { \\ } \end{_overlayalign_orig_starred_align:} } { } }{ } \ExplSyntaxOff % Source - https://tex.stackexchange.com/a/682151 % Posted by samcarter_is_at_topanswers.xyz, modified by community. See post 'Timeline' for change history % Retrieved 2026-03-30, License - CC BY-SA 4.0 \newlength{\gapwidth} \makeatletter \newcommand{\doblankQ}[1]{% \ifmmode \if@display \settowidth{\gapwidth}{$\displaystyle #1$}% \else \settowidth{\gapwidth}{$#1$}% \fi \else \settowidth{\gapwidth}{#1}% \fi \alert<.(1)>{% \alt<+->{% #1% }{% \vphantom{#1}\smash{\underline{\makebox[\gapwidth]{?}}}% }% }% } \makeatother \begin{document} \begin{frame} \begin{overlayalign} \begin{align} 4(2 + 8) & = 4(2) + 4(\doblankQ{8})\\ x(a + b) & = x(a) + x(b)\\ 4(2 + 8) & = 4(2) + 4(\doblankQ{8}). \end{align} \end{overlayalign} \end{frame} \end{document} It produces the following output. For both lines 1 and 3, I would like the line numbers to be shown one overlay earlier.

  • Fullpage vs geometry
    by Sebastiano on March 30, 2026 at 12:33 pm

    I am trying to understand the differences between the fullpage package (e.g. \usepackage[cm]{fullpage}) and the geometry package for setting page margins. From what I see, both seem to adjust margins, but I am not sure: In which situations is it appropriate to use fullpage? When should I prefer geometry instead? Are there any limitations or drawbacks of fullpage compared to geometry? Is one of them considered best practice today? For example, is there any reason to write: \usepackage[cm]{fullpage} instead of: \usepackage[a4paper, margin=2cm]{geometry} I would appreciate a clear explanation of the differences and recommendations for typical use cases.

  • ltx-talk: \visible command not working as I expected, part II
    by Svend Tveskæg on March 30, 2026 at 11:59 am

    This is a follow-up question to ltx-talk: \visible command not working as I expected. Code IMPORTANT: I'm not near a TeX distribution at the moment so I don't know if the following will compile but I think this is the code that I tested at home. % lualatex test.tex \DocumentMetadata{ lang = da, tagging = on } \documentclass[ danish ]{ltx-talk} \usepackage{pstricks} \begin{document} \begin{frame}{\visible<1->{Exercise}} \begin{center} \begin{pspicture}(1,1) \visible<2->{\psframe(0,0)(1,1)} \end{pspicture} \end{center} \end{frame} \end{document} Problem The problem described in the first part is now solved after updating ltx-talk but there is still a problem; if I put \visible<n->{...} (for n > 1) inside a pspicture environment, the behaviour with the picture being drawn right from the start of the frame persists.

  • Issue with kashida inside underline
    by Salim Bou on March 30, 2026 at 11:21 am

    This example of arabic text (babel with lualatex engine) does not give the desired result, text inside \underline with kashida activated displays an incorrect result. Used font Noto Naskh Arabic. \documentclass{article} \usepackage[bidi=basic]{babel} \babelprovide[import=ar, main, justification = kashida, transforms = kashida.base] {arabic} \babelfont{rm}{Noto Naskh Arabic} \begin{document} \large\bfseries \makebox[4cm][s]{سلام} \underline{\makebox[4cm][s]{سلام}} \end{document}

  • Fonts missing Italics in Arabic
    by Knudsen on March 29, 2026 at 7:32 pm

    If one produces a bibliography containing entries in Arabic, you are bound to have to use slanted text, no matter how rare this is in Arabic. Producing it in "Amiri", by Khaled Hosny, yields a text that has titles in slanted text just fine: But producing it either in Arial or Noto leaves the slanted text out and Arial is even missing a character: as one can see in this short MWE: \documentclass{article} \begin{filecontents}[overwrite]{arabic.bib} @book{Guillemin-Pollack:Persian, author = {Guillemin, Victor and Pollack, Alan}, title = {\foreignlanguage{arabic}{ﺕﻮﭘﻮﻟﻭﮋﯾ ﺪﯿﻓﺭﺎﻨﺴﯿﻟ ﻢﻗﺪﻣﺎﺘﯾ}}, publisher = {\foreignlanguage{arabic}{ﺱﺎﺤﻟ ﺎﻧﺪﯿﺸﻫ ﺖﻫﺭﺎﻧ }}, note = {\foreignlanguage{arabic}{ﺕﺮﺠﻤﻫ: ﻢﻫﺪﻳ ﻦﺠﻔﻳ ﺥﻭﺎﻫ}}, year = {2006}, pages = {108}, } @book { promenade:ar, AUTHOR = {Ghys, Étienne}, title = {\foreignlanguage{arabic}{ﻥﺯ ﻩﺓ ﺓﺭﺎﻴﻀﻳﺎﺘﻳ}}, note = {\foreignlanguage{arabic}{ﺕﺮﺠﻣﺓ: ﺢﻣﺯﺓ ﺦﻠﻴﻓ}}, PUBLISHER = {ENS Éditions}, address = {Lyon}, YEAR = {2023}, PAGES = {318}, } @book{polya-ar, author = {Pólya, George}, title = {\foreignlanguage{arabic}{ﻚﻴﻓ ﺖﺤﻟ ﻢﺳﺎٔﻟﺓ ﺮﻳﺎﻀﻳﺓ : ﻢﻨﺣﻯ ﺝﺪﻳﺩ ﻒﻳ ﺎﻠﻃﺮﻴﻗﺓ ﺎﻟﺮﻳﺎﻀﻳﺓ }}, publisher = {\foreignlanguage{arabic}{ﺎﻠﻤﻨﻈﻣﺓ ﺎﻠﻋﺮﺒﻳﺓ ﻞﻠﺗﺮﺠﻣﺓ،}}, address = {\foreignlanguage{arabic}{ ﺐﻳﺭﻮﺗ، ﻞﺒﻧﺎﻧ}}, date = {2016}, } \end{filecontents} \usepackage{fontspec} \usepackage{csquotes} \usepackage[english, bidi=basic-r]{babel} \babelprovide[import=ar, mapdigits, language=Default]{arabic} \babelfont{rm}{Times New Roman} % Default font for LTR \babelfont[arabic]{rm}{Arial} % No italic, missing a character %\babelfont[arabic]{rm}{Noto Naskh Arabic} % No italic %\babelfont[arabic]{rm}{Amiri} % Has upright and slanted \usepackage[backend=biber, style=authoryear, autolang=other, url=false, isbn=false, language=auto]{biblatex} \addbibresource{arabic.bib} \begin{document} \nocite{*} \printbibliography \end{document} Is italics missing in two widely distributed fonts, by design, or something wrong with this LaTeX set-up? Same for the missing character in Arial? Obs: Traditional italics are rare in Arabic, and "slanted" Arabic is almost entirely a modern, Western-influenced invention. Arial and Arial Italic are distributed with Windows and MacOS. For Unix one can install it using sudo apt install ttf-mscorefonts-installer. NoTO is OpenSource and distributed by Google.

  • Beamer miniframes: side-by-side gets shifted when \beamergotobutton
    by scottkosty on March 29, 2026 at 5:18 pm

    I am using code that makes it so the mini frames are on the same line as the section names. However, when I remove navigation symbols and use \beamergotobutton{}, the mini frames can "jump" (i.e., have vertical shift). The problem does not occur if I use "smoothbars" instead. I have the following example file, modified from Beamer miniframes: side-by-side section names and navigation dots. % Source - https://tex.stackexchange.com/a/88403 % Posted by diabonas, modified by community. Modified again by scottkosty to show problem. % Retrieved 2026-03-29, License - CC BY-SA 3.0 \documentclass[compress]{beamer} % using "smoothbars" does not give the same behavior. \useoutertheme[subsection=false]{miniframes} % remove the navigation bar \setbeamertemplate{navigation symbols}{} \usepackage{etoolbox} \makeatletter \patchcmd{\slideentry}{\advance\beamer@tempdim by -.05cm}{\advance\beamer@tempdim by\beamer@vboxoffset\advance\beamer@tempdim by\beamer@boxsize\advance\beamer@tempdim by 1.2\pgflinewidth}{}{} \patchcmd{\slideentry}{\kern\beamer@tempdim}{\advance\beamer@tempdim by 2pt\advance\beamer@tempdim by\wd\beamer@sectionbox\kern\beamer@tempdim}{}{} \makeatother \begin{document} \section{Sec 1} \subsection{} \frame{}\frame{hello \beamergotobutton{anything}}\frame{}\frame{} \section{Sec 2} \subsection{} \frame{}\frame{}\frame{}\frame{} \end{document} I get the following output. The problem can be seen on the second image of the sequence. On the second image, the first mini frame dot is shifted upwards for some reason.

  • Why is "every [shape] node" applied after node options?
    by karlh on March 29, 2026 at 3:35 pm

    As a sort of follow-up to a previous question, why is "every [shape] node" applied after node options? For example, \documentclass[tikz]{standalone} \begin{document} \begin{tikzpicture}[every rectangle node/.style={draw=black, minimum width=1cm,minimum height=1cm}] \node [rectangle] {hello!}; \node [rectangle] at (2.5,0) {hello again!}; \node [rectangle,minimum height=2cm] at (0,-2) {Hello, world!}; \bgroup \tikzset{every rectangle node/.style={draw=black,minimum width=1cm, minimum height=2cm}} \node [rectangle] at (2.5,-2) {Hello, world!}; \egroup \node [rectangle] at (0,-3.75) {goodbye!}; \end{tikzpicture} \end{document} which produces The two "Hello, world!" boxes should look the same, but because of the order in which things are applied, they do not. Creating a group with "every rectangle node" fixes it, as in the example, but is cumbersome. (The bgroup...egroup guards prevent the \tikzset settings from propagating to the rest of the picture, too.) My main question: Why is "every [shape] node" applied after the node options, overriding what is (presumably) the user's choice for that particular object, and is there interest from TikZ developers in changing that default to restore what seems to me to be the more intuitive behavior, that is, applying the "every [shape] node" settings just before the node's optional arguments, so the optional arguments override anything that is applied "globally"? If it would be helpful for me to raise this as an issue on Github, I can do that.

  • Draw a TikZ path behind cell content and rules in nicematrix
    by projetmbc on March 29, 2026 at 2:47 pm

    I want to draw a TikZ connector between two cells in a NiceTabular, but the path always appears on top of the rules (hvlines) and the text. If I use \CodeAfter, it's on top, and I can't use \CodeBeforebecause the nodes (i-j) are not recognized. How can I draw this path on the background layer? \documentclass[border = 3pt]{standalone} \usepackage{nicematrix} \usepackage{tikz} \begin{document} \renewcommand{\arraystretch}{1.2} \begin{NiceTabular}{>{\bfseries}*{6}{c}}[ hvlines, corners = NW, ] \RowStyle{\bfseries} & A & B & C & D & E \\ A & & & 1 & 1 & \\ B & & & & 1 & 1 \\ C & 1 & & & & 1 \\ D & 1 & 1 & & & \\ E & & 1 & 1 & & % \CodeAfter \tikz\draw[red, ->] (4-1.east) -| (1-2.south); \end{NiceTabular} \end{document}

  • Keeping underlined text within the confines of the margins
    by user143462 on March 29, 2026 at 2:40 pm

    How do I modify the \newcommand in the preamble in order for the underlined text to be properly contained by the margins? I got it here: underline omitting the descenders. Also, my code will not compile without the \usepackage{tikz} in the preamble. I don't have a tikzpicture environment in my code. This is bizarre. \documentclass[10pt]{amsart} \usepackage{soul} \usepackage{tikz} \makeatletter \newcommand*{\whiten}[1]{\llap{\textcolor{white}{{\the\SOUL@token}}\hspace{#1pt}}} \DeclareRobustCommand*\myul{% \def\SOUL@everyspace{\underline{\space}\kern\z@}% \def\SOUL@everytoken{% \setbox0=\hbox{\the\SOUL@token}% \ifdim\dp0>\z@ \raisebox{\dp0}{\underline{\phantom{\the\SOUL@token}}}% \whiten{1}\whiten{0}% \whiten{-1}\whiten{-2}% \llap{\the\SOUL@token}% \else \underline{\the\SOUL@token}% \fi}% \SOUL@} \begin{document} In 2007, a team led by Alice Storey analyzed a chicken bone found in El Arenal, Chile, dating it to 1321--1407 CE~---~over a century before Europeans invaded the region, bringing their own chickens. Storey also found that the El Arenal chicken shared a unique genetic mutation with the ancient chicken breeds of the Polynesian Islands in the Pacific. Thus, \myul{Polynesian peoples, not later Europeans, probably first introduced chickens to South America.} \end{document}

  • What is a better approach to plot the double path style as a subpath?
    by Explorer on March 29, 2026 at 3:03 am

    I want to replicate something as below: Now is my code, but good with the conjunction (the double path's start and end, and the glitch of double), even with line join=round: \documentclass[tikz,border=5pt]{standalone} \begin{document} \begin{tikzpicture}[line join=round] \coordinate (start) at (0,1.5); \coordinate (end) at (0,0); \draw[magenta] (start) -- ++(3,0) coordinate (doublestart) ++(-.5,-1.5) coordinate (doubleend) -- (end); \draw[cyan,double,double distance=2.5pt] (doublestart) .. controls ++(.25,-.75) and ++(-.3,1) .. (doubleend) ; \end{tikzpicture} \end{document}

  • Embracing the present and future of LaTeX: where to start?
    by PHL on March 29, 2026 at 1:14 am

    Which ressources (and in which order) would you recommend to (re)learn modern LaTeX for an advanced user that learned LaTeX twenty years ago? I have the impression that many things have changed these past years: NewDocumentCommand, hooks, standard packages that became obsolete, useful things that have been moved to the kernel, utf8 support out of the box, … I thus need to update my LaTeX knowledge, but I am unsure to where to start. A document summarising the changes would be invaluable, but might not exist. An alternative would be recent ressources that assume some familiarities with TeX. If none of these exists, an introductory text will do. The emphasis is on learning things that will be useful in the present, but also in the future. Using experimental methods/packages is not a problem if there are good indications that they will be standard at some point in the future. On the opposite, I would like to avoid learning standard methods/packages that are doomed to be obsolete/deprecated soon. For context: I started to use TeX 20 years ago. At the time I read lshort, The LaTeX Companion (2e) and the TeXbook. This allowed me to became an advanced user of LaTeX and produce documents of far better quality than the one produced by some old professors still using deprecated methods and preamble full of outdated packages. With the years passing I started to add more and more packages to my preamble, as fixltx2e, to finally discover that they became obsolete. A lot has happened these past 20 years and it seems reasonable to start anew in order to unlearn old habits and learn new ones.

  • Different types of lines in tree diagram
    by user242399 on March 27, 2026 at 5:25 pm

    I am making a horizontal tree diagram and want the lines (or part of them) to look different in different parts of the diagram. I want to use continuous and dashed lines. Below is an example of what I want to be able to do. I want the lines to be dashed near the root and continuous as they get close to the nodes. The lines can be slightly curved or not, but I specifically do not want them to meet at the root. And a MWE: \documentclass[tikz,border=2mm]{standalone} \usetikzlibrary{trees} \begin{document} \begin{tikzpicture}[ grow=right, level distance=3cm, sibling distance=1.5cm, every node/.style={thick, minimum size=8mm} ] \node {Root} child [edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)}, dashed] { node {C} } child [edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)}, dashed] { node {B} child [edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)}, solid] { node {B3} } child [edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)}, solid] { node {B2} } child [edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)}, solid] { node {B1} } } child [edge from parent path={(\tikzparentnode.east) -- (\tikzchildnode.west)}, dashed] { node {A} }; \end{tikzpicture} \end{document}

  • Ignoring the tail of the letter "g" in setting the baseline of text in nodes of a tikz diagram
    by user143462 on March 27, 2026 at 4:22 pm

    I would like the baseline of "with nitrogen" to be aligned with the bottom edge of the square shaded gray. The bottom of the tail (descender) in the "g" is currently setting the baseline for the phrase. I tried using \makebox[0pt]. Same edit for the other node. \documentclass[10pt]{amsart} \usepackage{tikz} \begin{document} \begin{tikzpicture}[x=1cm,y=1.5cm] %The key is drawn. The keys in other bar graphs have sample regions that are squares with edge length 0.25 centimeters. As the vertical dimension is scaled by 150%, the heights of the sample squares must be scaled by 2/3. \path[fill=gray] (6, {2 + (2/3)*0.125}) -- (6.25, {2 + (2/3)*0.125}) -- (6.25, {2 + (2/3)*0.375}) -- (6, {2 + (2/3)*0.375}) -- cycle; \draw (6, {2 +(2/3)*0.125}) -- (6.25, {2 +(2/3)*0.125}) -- (6.25, {2+(2/3)*0.375}) -- (6, {2+(2/3)*0.375}) -- cycle; \node[anchor=south west, inner sep=0, font=\small] at (6.375, {2 + (2/3)*0.125}){\makebox[0pt][l]{with nitrogen}}; \path[fill=black] (6, {2 - (2/3)*0.125}) -- (6.25, {2 - (2/3)*0.125}) -- (6.25, {2 - (2/3)*0.375}) -- (6, {2 - (2/3)*0.375}) -- cycle; \draw (6, {2 - (2/3)*0.125}) -- (6.25, {2 - (2/3)*0.125}) -- (6.25, {2 - (2/3)*0.375}) -- (6, {2 - (2/3)*0.375}) -- cycle; \node[anchor=south west, inner sep=0, font=\small] at (6.375, {2 - (2/3)*0.375}){without nitrogen}; \draw (5.875, {2 - (2/3)*0.5}) -- (5.875, {2 + (2/3)*0.5}) -- (8.85, {2 + (2/3)*0.5}) -- (8.85, {2 - (2/3)*0.5}) -- cycle; \end{tikzpicture} \end{document}

  • tabular text besides image
    by Viesturs on March 27, 2026 at 12:32 pm

    In a tabular environment, text needs to be placed symmetrically besides a drawing: Code: \documentclass[a4paper]{article} \usepackage{graphicx} \begin{document} \begin{tabular}[t]{@{}c@{\hspace{0.5cm}} l@{}} \includegraphics[width=0.9cm]{example-image-a} & \begin{minipage}[t]{10cm} % [t] ensures top alignment line 1\\ line 2\\ \end{minipage} \end{tabular} \end{document} Output: Text is hanging below the image. How to place the image and text side by side symmetrically?

  • Defining list of commands using \foreach
    by Lorenzo Riva on March 25, 2026 at 11:02 pm

    I want to use a \foreach loop to define a series of commands of the form \bf\l where \l runs through the uppercase letters of the alphabet and \bf\l evaluates to \mathbf{\l}. This is so that I don't have to manually define \bfA, \bfB, etcetera at the start of all my documents. I've tried the following setup (patched together from Defining a newcommand, with variable name, inside another newcommand): \documentclass{article} \usepackage{amsmath,pgffor} \foreach \l in {A,B,C,D} { \expandafter\newcommand\csname bf\l\endcsname{ \mathbf{\l}% } } \begin{document} $\bfA$ $\bfB$ $\bfC$ $\bfD$ \end{document} It resulted in four errors, namely that the four commands are undefined. Where am I going wrong, and why does this not work?