Hot
- Color terminal output: Partial success, but not full successby rallg on February 20, 2026 at 7:56 pm
I have searched for various ways to colorize text that appears in Terminal. In general, they fail miserably with lualatex (and may also fail with others, but I did not check). When I first posted this question, I showed a MWE that partially worked. Thanks to Marcel's comment, I realized that I had mingled Lua and TeX syntax, so that MWE could fail. This is a revised MWE that works well. Since others have asked this question, I provide the good MWE now: \documentclass{article} %% compile with lualatex %% Usage: \directlua{terminal_color("N", "Message")} %% Where N is the terminal color code, such as 32 for green. \directlua{ function terminal_color(color_code, text) texio.setescape(0) texio.write_nl("\string\x1B[" .. color_code .. "m" .. text .. "\string\x1B[0m") texio.setescape(1) end }%% \begin{document} \directlua{texio.write_nl("This terminal text is normal color.")} \directlua{terminal_color("32", "This terminal text is green.")} \directlua{texio.write_nl("Normal terminal color.\string\nReally.")} %% Works. \end{document}
- How to colour only the first box in a \multicolumn table row with fixed heightby Jon on February 20, 2026 at 7:33 pm
I have included the full document because the behaviour only occurs in this context. In the final \multicolumn row of the table, I am constructing a row that visually consists of several fixed-width boxes separated by vertical rules. I want only the first box in that row to have a background colour, with: a consistent row height, the colour filling the box exactly (no padding), the colour reaching the vertical rule, and no colour bleed into adjacent boxes. At the moment, attempts to enforce row height using struts or rules either do not affect the height or cause alignment/bleed issues when combined with colour. What is the correct and robust way to colour only the first fixed-width box in this kind of composite table row while maintaining consistent height and clean rule alignment? (I am open to restructuring the table if there is a better construction.) % !TeX program = xelatex % !TeX spellcheck = en_GB \documentclass[12pt,addpoints]{exam} % ----------------------------- % Maths % ----------------------------- \usepackage{amsmath, amssymb} \usepackage{bm} % ----------------------------- % Graphics & layout % ----------------------------- \usepackage{graphicx} \usepackage{float} \usepackage{pdfpages} \usepackage{geometry} \usepackage{parskip} \usepackage{multicol} % ----------------------------- % TikZ / plots (kept, but minimal) % ----------------------------- \usepackage{tikz} \usetikzlibrary{math, calc} \usepackage{pgfplots} \usepackage{tkz-base} \usepackage{tkz-euclide} \usepackage{tikz-3dplot} \usepackage{tikzlings} \usepackage{tikzpeople} \usepackage{geometry} % ----------------------------- % Fonts (LuaLaTeX) % ----------------------------- \usepackage{fontspec} \setmainfont{Aptos} \usepackage{unicode-math} \setmathfont{Cambria Math} % ----------------------------- % Tables & colour % ----------------------------- \usepackage{xcolor} \usepackage{array} \usepackage{colortbl} % ----------------------------- % Exam class configuration % ----------------------------- \marksnotpoints \qformat{\textbf{Task \thequestion\hfill (\thepoints)}} % ----------------------------- % Page geometry & header % ----------------------------- \newgeometry{ left=2.25cm, right=2cm, top=1.4cm, bottom=0cm } % ----------------------------- % Utility commands % ----------------------------- \newcommand{\uline}[1]{\rule[0pt]{#1}{0.4pt}} \newcommand\dunderline[3][-1pt]{% \sbox0{#3}% \ooalign{\copy0\cr\rule[\dimexpr#1-#2\relax]{\wd0}{#2}}% } \renewcommand{\arraystretch}{2} \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} % ----------------------------- % Footer % ----------------------------- \footer{}{\textbf{End of Questions}}{\scriptsize Page \thepage\ / \numpages} \firstpagefooter{}{}{} \extraheadheight[20pt]{20pt}% addded <<<<<<<<<<<<<<<<<< \definecolor{wordgrey}{RGB}{166,166,166} \usepackage[table]{xcolor} \hyphenpenalty=10000 \exhyphenpenalty=10000 \begin{document} \renewcommand{\arraystretch}{1.8} \setlength{\arrayrulewidth}{1pt} \vspace*{-0.25cm} \noindent \setlength{\arrayrulewidth}{0.5pt} \noindent\hspace*{-0.19cm} \begin{tabular}{|p{3.7cm}|p{12.8cm}|} \hline \fontsize{12pt}{14pt}\selectfont\textbf{Something} & Something \\ \hline \fontsize{12pt}{14pt}\selectfont\textbf{Something} & Something \\ \hline \fontsize{12pt}{14pt}\selectfont\textbf{Time Allowed} & \\ \hline \fontsize{12pt}{14pt}\selectfont\textbf{Something} & \\ \hline \fontsize{12pt}{14pt}\selectfont\textbf{Something } & {\fontsize{11}{13}\selectfont \setlength{\labelsep}{1.7em} \setlength{\leftmargini}{3.6em} \begin{itemize} \item One \item \item \item \item \item \item \end{itemize} } \\ \hline \textbf{Something} & \cellcolor{wordgrey} \fontsize{11pt}{13pt}\selectfont \textbullet\ \hspace{0.4cm} Section \\ \cline{2-2} & \fontsize{11pt}{13pt}\selectfont \textbullet\ \hspace{0.4cm} Section \\ \cline{2-2} \hline \textbf{\mbox{ Something}} & \fontsize{11pt}{13pt}\selectfont \textbullet\ \hspace{0.4cm} \\ \hline \multicolumn{2}{|l|}{\hspace*{3.95cm}\fontsize{12pt}{14pt}\selectfont [ something]} \\ \hline \multicolumn{2}{|l|}{% \fontsize{11pt}{13pt}\selectfont \colorbox{wordgrey}{\makebox[3.0cm][l]{\textbf{1. No AI}}}% \vrule width 0.5pt\hspace{0.4em}% \colorbox{white}{\makebox[3.2cm][l]{\textbf{2. AI Planning}}}% \vrule width 0.5pt\hspace{0.4em}% \colorbox{white}{\makebox[4.3cm][l]{\textbf{3. AI Collaboration}}}% \vrule width 0.5pt\hspace{0.4em}% \colorbox{white}{\makebox[2.7cm][l]{\textbf{4. Full AI}}}% \vrule width 0.5pt\hspace{0.4em}% \colorbox{red}{\makebox[3.0cm][l]{\textbf{5. AI Exploration}}}% } \\ \hline \multicolumn{2}{|l|}{% \fontsize{11pt}{13pt}\selectfont {\cellcolor{wordgrey}\makebox[3.0cm][l]{\textbf{1. No AI}}}% \vrule width 0.5pt\hspace{0.4em}% {\cellcolor{white}\makebox[3.2cm][l]{\textbf{2. AI Planning}}}% \vrule width 0.5pt\hspace{0.4em}% {\cellcolor{white}\makebox[4.3cm][l]{\textbf{3. AI Collaboration}}}% \vrule width 0.5pt\hspace{0.4em}% {\cellcolor{white}\makebox[2.7cm][l]{\textbf{4. Full AI}}}% \vrule width 0.5pt\hspace{0.4em}% {\cellcolor{red}\makebox[3.0cm][l]{\textbf{5. AI Exploration}}}% } \\ \hline \multicolumn{2}{|l|}{% % Match your font settings for the whole inner row \fontsize{11pt}{13pt}\selectfont % Inner table that actually draws the five boxes with rules \setlength{\arrayrulewidth}{0.5pt}% make rules 0.5pt as in your \vrule \arrayrulecolor{black}% \begin{tabular}{@{} >{\raggedright\arraybackslash}p{2.8cm} | >{\raggedright\arraybackslash}p{3.2cm} | >{\raggedright\arraybackslash}p{4.1cm} | >{\raggedright\arraybackslash}p{2.7cm} | >{\raggedright\arraybackslash}p{3.0cm} @{}} \cellcolor{wordgrey}\textbf{1. No AI} & \textbf{2. AI Planning} & \textbf{3. AI Collaboration} & \textbf{4. Full AI} & \textbf{5. AI Exploration} \end{tabular}% } \\ \multicolumn{2}{|l|}{% \fontsize{11pt}{13pt}\selectfont \cellcolor{wordgrey}\makebox[3.0cm][l]{\textbf{1. No AI}}% \vrule width 0.5pt\hspace{0.4em}% \cellcolor{red} \makebox[3.2cm][l]{\textbf{2. AI Planning}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[4.3cm][l]{\textbf{3. AI Collaboration}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[2.7cm][l]{\textbf{4. Full AI}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[3.0cm][l]{\textbf{5. AI Exploration}}% } \\ \hline \multicolumn{2}{|l|}{% \fontsize{11pt}{13pt}\selectfont % First box: grey background only for this box \begingroup\setlength{\fboxsep}{0pt}% \colorbox{wordgrey}{% \makebox[3.0cm][l]{\textbf{1. No AI}}% }% \endgroup \vrule width 0.5pt\hspace{0.4em}% % Remove the red — it was causing the bleed \makebox[3.2cm][l]{\textbf{2. AI Planning}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[4.3cm][l]{\textbf{3. AI Collaboration}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[2.7cm][l]{\textbf{4. Full AI}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[3.0cm][l]{\textbf{5. AI Exploration}}% } \\ \hline \multicolumn{2}{|l|}{% \fontsize{11pt}{13pt}\selectfont % ---- First box: solid grey, exactly 3.0cm, with enforced height ---- \begingroup \setlength{\fboxsep}{0pt}% no padding so it fills exactly 3.0cm \colorbox{wordgrey}{% % The inner makebox *sets the width*. The \rule sets the row height. \makebox[3.0cm][l]{\rule{0pt}{3.2ex}\textbf{1. No AI}\rule[-1.2ex]{0pt}{0pt}}% }% \endgroup % Immediately draw the vertical rule so the grey reaches it \vrule width 0.8pt\hspace{0.5em}% % ---- Remaining boxes: unchanged, uncolored ---- \makebox[3.2cm][l]{\textbf{2. AI Planning}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[4.3cm][l]{\textbf{3. AI Collaboration}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[2.7cm][l]{\textbf{4. Full AI}}% \vrule width 0.5pt\hspace{0.4em}% \makebox[3.0cm][l]{\textbf{5. AI Exploration}}% } \\ \hline \end{tabular} \newpage \begin{questions} \question \end{questions} \end{document}
- Make all subtables as height as the pages (table spanning multiple pages)by cis on February 20, 2026 at 6:54 pm
I have a table spanning multiple pages, and it shall have textwidth. So I chose xltabular (to leverage the advantages of tabularx and longtable [note: the number of columns p1, p2, ... is variable in the original]). (And yes, I also need pgfplotstable in the end.) The question is: Is there a simple way to make all the subtables have textheight? Therefore, the distance to the footer should be increased accordingly. Note: I set paperheight=58mm to better illustrate the problem. \documentclass[paper=a5]{scrreprt} \usepackage[margin=14mm, showframe=true, paperheight=58mm, ]{geometry} \usepackage{pgfplotstable} \pgfplotsset{compat=1.18} \usepackage{xltabular} \newcolumntype{Y}{>{\centering\arraybackslash}X@{\hspace{5pt}}} \begin{document} % Create some table-data ===================== \def\OutFilename{\jobname-data.csv} \newwrite\MyFile \immediate\openout\MyFile=\OutFilename % \foreach[count=\No from 0] \n in {1,...,4}{%% \foreach \k in {0,...,\n}{ \immediate\write\MyFile{\n, \k, 0.1111, 0.2222, 0.3333, 0.4444, 0.5555, 0.6666, 0.7777, \k, \No} }%% } \immediate\closeout\MyFile % =================================== \noindent% \pgfplotstabletypeset[ precision=4, skip 0.,% number format header=true, font=\footnotesize, column type=, begin table=\begin{xltabular}{\textwidth}{c c | *{7}{Y} | c l}, end table=\end{xltabular}, col sep=comma, every head row/.style={%% output empty row, before row={% %% Very first Header ======================== \hline n & k & p1 & p2 & p3 & p4 & p5 & p6 & p7 & k & N \\ \hline \endfirsthead %% Header for subsequent pages ================ \hline n & k & P1 & P2 & P3 & P4 & P5 & P6 & P7 & k & N \\ \hline \endhead %% Footer for all pages except last ================ \hline n & k & q1 & q2 & q3 & q4 & q5 & q6 & q7 & k & N \\ \hline \endfoot %% Footer for the very last page ================ \hline n & k & Q1 & Q2 & Q3 & Q4 & Q5 & Q6 & Q7 & k & N \\ \hline \endlastfoot },% end of 'before row' %% },%% end of 'every head row/.style' %% ]{\OutFilename} \end{document}
- Draw these figures using only tikz [closed]by Jose G Lopez on February 20, 2026 at 5:02 pm
Good afternoon everyone, I'd like to know how I can make this figure in Tikz, as I want to learn.
- How to draw self-overlapped path with double line style?by Explorer on February 20, 2026 at 4:52 pm
The question is similar to this solution, but not the same: \documentclass[tikz, border=1cm]{standalone} \usetikzlibrary{decorations.pathreplacing} % https://tex.stackexchange.com/a/572738/322482 \begin{document} \begin{tikzpicture}[ rounded corners=1pt, path decomposition/.style={% postaction={decoration={show path construction, lineto code={ \draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast); }, curveto code={ \draw[#1] (\tikzinputsegmentfirst) .. controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast) ; }, closepath code={ \draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast) {closepath};} } ,decorate}}] \draw[line cap=round, black, double=gray!10, thick, path decomposition={black, double=gray!10,thick}] (3,3) -- (1,1) -- (3,1) -- (1,3); % here below is what I want with only one path \begin{scope}[xshift=3cm] \draw[black, double=gray!10, thick, line cap=round] (3,3) -- (1,1) -- (1.5,1); \draw[black, double=gray!10, thick, line cap=round] (2.5,1) -- (3,1) -- (1,3); \draw[black, double=gray!10, thick] (1.3,1) -- (2.7,1); \end{scope} \end{tikzpicture} \end{document}
- Memoize not working for certain equation environmentsby jayo8589 on February 20, 2026 at 4:32 pm
Good day, thank you very much for taking the time to read this. I am working on a mathematics book for high school students, which is quite extensive (between 500 and 1000 pages). The project contains numerous equations and graphics using TikZ, annotate-equations, etc. My goal is to speed up the compilation time. My workflow is based on Windows, MiKTeX with Perl, VS Code with LaTeX Workshop, and LuaLaTeX with latexmk. To accelerate the compilation, I am using the memoize package, which externalizes not only graphics but also equation environments like align, etc. However, I am facing the following issues: Memoize does NOT externalize starred equation environments such as \begin{equation*}, \begin{align*}, etc. Only the unstarred versions (\begin{equation}, \begin{align}) appear as externalized. The displaymath environment [ ... ] is not being taken into account for externalization. In the actual project, I get a huge number of .memo files without their corresponding PDFs, which suggests that the externalization process is not being completed. What could be the problem? How should memoize be correctly configured? How can I ensure that all starred equation environments, including the displaymath [ ... ] shorthand, are properly externalized? \documentclass{book} \usepackage{docmute} \usepackage{memoize} \mmzset{ memo dir=Chapters/main, auto={tikzpicture}{memoize}, auto={tcolorbox}{nomemoize}, auto={mynote}{nomemoize}, % Entornos estándar y amsmath auto={displaymath}{memoize, capture=vbox}, auto={equation}{memoize, capture=vbox}, auto={eqnarray}{memoize, capture=vbox}, auto={align}{memoize, capture=vbox}, auto={gather}{memoize, capture=vbox}, auto={alignat}{memoize, capture=vbox}, auto={multline}{memoize, capture=vbox}, auto={flalign}{memoize, capture=vbox}, } \usepackage{tikz} \usepackage{tcolorbox} \usepackage{amsmath, amssymb, amsthm} \begin{document} Document Body ... \begin{align} a + b & = c \\ d + e & = f \quad \text{Align environment NOT (*)} \end{align} \begin{align*} 5x + 6y & = -55m \\ -9z + 2w & = -99n \quad \text{Align environment with (*)} \end{align*} \begin{equation} -5x^2+4y^2=-3 \quad \text{Equation environment with NOT (*)} \end{equation} \begin{equation*} -5x^2+4y^2=-3 \quad \text{Equation environment WITH (*)} \end{equation*} \[ y=mx+b \quad \text{Display Math environment } \] \begin{multline} y=-4x^2+8x+8+4444444444 \quad \text{Multline environment NOT (*)} \end{multline} \begin{multline*} y=-8x^2+8x+8+8888888888 \quad \text{Multline environment WITH (*)} \end{multline*} \end{document} I would greatly appreciate any help you can provide. Thank you in advance.
- Does (Lua)TeX use .notdef or U+FFFD?by rallg on February 20, 2026 at 3:57 pm
Simple (I hope) question. Does not need MWE. I use LuaLaTeX, although I expect that this question is generally applicable. If a font does not have a requested Unicode character, does (Lua)LaTeX insert a .notdef glyph there, or does it insert U+FFFD (if the font has U+FFFD) ? Does this depend on circumstances (such as math/text mode, etc.) ? I am not worried about intentionally contrived situations that would never occur in a real document. Reason I ask: I design and use my own fonts, which have U+FFFD. Since this is a valid Unicode location, I can do font-related tricks with it, such as using OpenType features to show different glyphs, depending on the problem. But I cannot do them with .notdef, because it is not a valid Unicode location. I dimly recall reading (here at SE) that U+FFFD is used, if found, but I cannot find that thread. Search returns XeTeX-specific info, and I do not use that.
- xsim: shortsolutions chapter by chapterby chriho on February 20, 2026 at 3:34 pm
I have a collection of xsim exercises, each of which has a solution and shortsolution implemented. In my exercises-collection document, I want to print the solutions or shortsolutions (depending on a toggle) chapter by chapter (or section by section). To define the shortsolutions, I mainly use the definition from the xsim-manual: % new property: \DeclareExerciseProperty{shortsolution} % new environment: \NewDocumentEnvironment{shortsolution}{+b} {% \edef\ExerciseType{\csname g_xsim_exercise_type_tl\endcsname}% \edef\ExerciseID{\csname g_xsim_exercise_id_tl\endcsname}% \SetExerciseProperty{shortsolution}{#1}% } {} % we'll use a description list for the list of short solutions: \newcommand\printshortsolutions{% \begin{description} \ForEachUsedExerciseByType{% \GetExercisePropertyT{shortsolution} {\item[Short Solution ##3]####1}% }% \end{description} } While \printsolutions[chapter={true}] works as expected, the option \printshortsolutions[chapter={true}] unfortunately does not work. Here, the short solutions of all chapters are printed every time.
- Advantage of \csname over \makeatletter (inside \pgfkeys/\tikzset)?by Sammy on February 20, 2026 at 3:29 pm
In this answer https://tex.stackexchange.com/a/133357 to a question regarding TikZ I found the following comment inside a \tikzset: % Use csname so catcode of @ doesn't have do be changed. This leaves me wondering if using \csname has any advantage over changing the catcode of @ by wrapping \tikzset with \makeatletter - which inside a package wouldn't even be neccesary since inside a package @ is of catcode letter by default. Is the use of \makeatletter potentially problematic (in general or inside pgfkeys)? If so: In which cases is it advisable to use \csname instead of \makeatletter? As far as I can imgine it (practically?) should be just a matter of taste, otherwise using such code inside a package where @ is of catcode letter would be problematic?!
- `tcolorbox` + `lualineno`: line numbering disappears when a title is usedby cjorssen on February 20, 2026 at 3:03 pm
I am using LuaLaTeX together with tcolorbox and the new lualineno package. The intended behaviour is to apply line numbering exclusively to the upper part of a tcolorbox (the box body), while leaving the title unaffected. With the minimal example below, line numbering behaves differently depending on whether the box has a title. \documentclass{article} \usepackage{tcolorbox} \usepackage{pgffor} \usepackage{lualineno} \newcounter{lineno} \lualineno{% define = { name = default toks = {\stepcounter{lineno}} left = {\tiny\thelineno \kern.8em} } } \begin{document} Some text before the box. \begin{tcolorbox}[ % title = Test, before upper = {\lualineno{set = default}}, after upper = {\lualineno{unset}} ] \foreach \n in {1,...,30}{ \noindent This is line \n. \\ } \end{tcolorbox} Some text after the box. \end{document} Observed behavior: Without a title (title commented out): Line numbers appear correctly outside the box. With a title (title = Test uncommented): Line numbers disappear. No compilation error or warning is produced. If the box is made breakable, I observe a related but slightly different effect: with a titled breakable box, line numbers disappear in the first segment of the box (before the page break). Adding a title should not affect line numbering inside the box. I would expect identical numbering behavior with or without a title. Is this interaction between tcolorbox and lualineno expected? Should lualineno be applied differently when titles are used? Any explanation of the underlying mechanism or guidance on proper usage would be greatly appreciated.
- Remove linebreak form clipboard textby rzickler on February 20, 2026 at 2:22 pm
I have code sections in my text that are highlighted with lstlisting. The line breaks are working and I get a (desired!) \hookrightarrow int the output text. So from this input TeX: My code: \begin{lstlisting} This is a long long long long long long long long long long long long long long long long long long line of code \end{lstlisting} I get this in the output PDF: Now I want to be able to copy and paste the code from the PDF to an editor. I was able to follow https://tex.stackexchange.com/a/649475/243557 to remove the (desired!) \hookrightarrow with the help of \usepackage{accsupp} from the clipboard on text copy. But the line break is still in the text. So if I copy+paste the above code from the PDF to my editor of choice I get the following result (works with Adobe Acrobat Reader): Note the line of code and the LF. Now my idea was to use the ANSI escape code for backspace in the ActualText={} of postbreak=\raisebox{0ex}[0ex][0ex]{\BeginAccSupp{ActualText={<BS-char-here>}}\ensuremath{\color{gray}\hookrightarrow\space}\EndAccSupp{}}, to somehow delete the line break from the clipboard text. I added the non visible BS-code directly but this did not result in the desired outcome (did not build). I also don't want to delete all line breaks just the ones that were added by lstlisting. Is this the right way to go or could I use some other technique to do the job. Notes: Code in a parallel documents is unfortunately not an option. Its a big PDF file with different code snippets. Furthermore, the PDF is our only allowed "source of truth". I know that the PDF reader plays an important role in this matter. But I'm fine if it is working with Adobe. Edit: Here is my listings setup: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \usepackage{accsupp} \lstset{ % Highlight line break due to textwidth % https://tex.stackexchange.com/questions/116534/lstlisting-line-wrapping postbreak=\raisebox{0ex}[0ex][0ex]{\BeginAccSupp{ActualText={}}\ensuremath{\color{gray}\hookrightarrow\space}\EndAccSupp{}}, breakatwhitespace = true, breaklines = true } \begin{document} My code: \begin{lstlisting} This is a long long long long long long long long long long long long long long long long long long line of code \end{lstlisting} \end{document} In a previous version I hat the input as Markdown. This is because I use Pandoc to convert to TeX and then to the PDF file. But the first step is not important for this problem and I replaced the Markdown with the converted TeX-Input.
- CV template - Side column size changes when footer is in first page?by Chip on February 20, 2026 at 1:10 pm
I'm trying to make a CV based on this Overleaf template. All my content fits on one page, so I wanted the footer to be on the first; for some unknown reason this changes the size of the left column and sends everything out of alignment. Minimal working example: % a mashup of hipstercv, friggeri and twenty cv % https://www.latextemplates.com/template/twenty-seconds-resumecv % https://www.latextemplates.com/template/friggeri-resume-cv \documentclass[lighthipster]{simplehipstercv} % available options are: darkhipster, lighthipster, pastel, allblack, grey, verylight, withoutsidebar % withoutsidebar \usepackage[utf8]{inputenc} \usepackage[default]{raleway} \usepackage[margin=1cm, a4paper]{geometry} %------------------------------------------------------------------ Variablen \newlength{\rightcolwidth} \newlength{\leftcolwidth} \setlength{\leftcolwidth}{0.23\textwidth} \setlength{\rightcolwidth}{0.75\textwidth} %------------------------------------------------------------------ \title{New Simple CV} \author{\LaTeX{} Ninja} \date{June 2019} \pagestyle{empty} \begin{document} \thispagestyle{empty} %------------------------------------------------------------- \section*{Start} \simpleheader{headercolour}{Jack}{Sparrow}{Captain}{white} %------------------------------------------------ % this has to be here so the paracols starts.. \subsection*{} \vspace{4em} \setlength{\columnsep}{1.5cm} \columnratio{0.23}[0.75] \begin{paracol}{2} \hbadness5000 %\backgroundcolor{c[1]}[rgb]{1,1,0.8} % cream yellow for column-1 %\backgroundcolor{g}[rgb]{0.8,1,1} % \backgroundcolor{l}[rgb]{0,0,0.7} % dark blue for left margin \paracolbackgroundoptions % 0.9,0.9,0.9 -- 0.8,0.8,0.8 \footnotesize {\setasidefontcolour \flushright \bg{cvgreen}{white}{About me}\\[0.5em] {\footnotesize \lorem\lorem\lorem} \bigskip \bg{cvgreen}{white}{personal} \\[0.5em] Jack Sparrow nationality: English 1690 \bigskip \bg{cvgreen}{white}{Areas of specialization} \\[0.5em] Privateering ~•~ Bucaneering ~•~ Parler ~•~ Rum \bigskip \bigskip \bg{cvgreen}{white}{Interests}\\[0.5em] \lorem \bigskip \bg{cvgreen}{white}{Interests}\\[0.5em] \texttt{R} ~/~ \texttt{Android} ~/~ \texttt{Linux} \texttt{R} ~/~ \texttt{Android} ~/~ \texttt{Linux} \texttt{R} ~/~ \texttt{Android} ~/~ \texttt{Linux} \vspace{4em} \infobubble{\faAt}{cvgreen}{white}{jack@sparrow.org} \infobubble{\faTwitter}{cvgreen}{white}{@sparrow} \infobubble{\faFacebook}{cvgreen}{white}{Jack Sparrow} \infobubble{\faGithub}{cvgreen}{white}{sparrow} \phantom{turn the page} \phantom{turn the page} } %----------------------------------------------------------- \switchcolumn \small [content] \vfill{} \pagebreak %---------------------------------------------------------------------------------------- % FINAL FOOTER %---------------------------------------------------------------------------------------- \setlength{\parindent}{0pt} \begin{minipage}[t]{\rightcolwidth} \begin{center}\fontfamily{\sfdefault}\selectfont \color{black!70} {\small Jack Sparrow \icon{\faEnvelopeO}{cvgreen}{} The Black Pearl \icon{\faMapMarker}{cvgreen}{} Tortuga \icon{\faPhone}{cvgreen}{} 0099/333 5647380 \newline\icon{\faAt}{cvgreen}{} \protect\url{jack@sparrow.com} } \end{center} \end{minipage} \end{paracol} \end{document} As you can see, the above code works fine, but if I comment out the \pagebreak just before the footer... Anyone have any idea of why, and how I could fix this?
- Thinspace with babel french?by nowox on February 20, 2026 at 12:47 pm
I love LaTeX, but I also love french typography and I noticed that babel does not really add a thin space before the colon/semicolon: \documentclass{article} \usepackage[french]{babel} \addto\extrasfrench{% \renewcommand{\FBcolonspace}{\nobreak\thinspace}% } \begin{document} \large Le canard: un animal avec deux pattes. \end{document} Built with: latexmk -lualatex test.tex If I manually do it, the result is visually much better. \begin{document} \large Le canard\nobreak\thinspace: un animal avec deux pattes. \end{document} Is there a way to tweak babel to do it right?
- GitHub and LaTeXby Tanda on February 20, 2026 at 12:20 pm
I need to be able to work on an Overleaf project while offline. I read tha I had to create a link with a repository on GitHub, which is what I did. All files are there, but how do I run LaTeX? Thanks to whomever will answer
- Class to typeset a journal: is memoir a good choice?by alcuinus on February 20, 2026 at 9:32 am
I normally use memoir to print my books. I am now editing a scholarly journal. Can I use memoir for this task? The main problem seems to redefine author for each chapter, Bibliography is at the end, I prefer a comprehensive list at the end of the journal. I saw the proc class but memoir seems much more developed.
- How to make good use of built-in Japanese sequence in `luatexja-otf` named `\ajKakuHira`-family in `luatexja-ajmacros.sty`?by Explorer on February 20, 2026 at 7:32 am
Learning from standard \alph and \@alph, I have the following code: \documentclass{article} \usepackage[sourcehan-jp]{luatexja-preset} \usepackage{enumitem} \makeatletter \newcommand{\hira}[1]{\expandafter\@hira\csname c@#1\endcsname} \def\@hira#1{\ifcase#1\or あ\or い\or う\or え\or お\or か\or き\or く\or け\or こ\or さ\or し\or す\or せ\or そ\or た\or ち\or つ\or て\or と\or な\or に\or ぬ\or ね\or の\or は\or ひ\or ふ\or へ\or ほ\or ま\or み\or む\or め\or も\or や\or ゆ\or よ\or ら\or り\or る\or れ\or ろ\or わ\or ゐ\or ゑ\or を\or ん\else\@ctrerr\fi} \AddEnumerateCounter{\hira}{\@hira}{あ} \makeatother \begin{document} \begin{enumerate}[label=(\hira*)] \item 第一 \item 第二 \item 第三 \item 第四 \item 第五 \end{enumerate} \end{document} gives: That is okay, but I need to move all the codes of numrical sequence everywhere(maybe I could put them into hira.tex and \input), I don't think that is the best practice, if I want Kata and Yobi at the same time(see below), I need to copy\def\@hira#1 twice. IMHO, I don't think that is Japanese LaTeX users' best approach to use these sequences. I found following commands in luatexja-ajmacros.sty could be found in luatexja-package: \@tempcnta\@ne \@aj@numberdef{Hira}あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん\@nil \@tempcnta\@ne \@aj@numberdef{Kata}アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン\@nil \@tempcnta\@ne \@aj@numberdef{Yobi}日月火水木金土祝休\@nil I want to make good use of it with \usepackage{luatexja-otf}, but I don't know whether they could interact with \AddEnumerateCounter: \documentclass{article} \usepackage[sourcehan-jp]{luatexja-preset} \usepackage{luatexja-otf} \usepackage{pgffor} \usepackage{enumitem} \begin{document} \foreach \x in {1,...,10}{ \ajKakuHira{\x}\par } % \bigskip % not work % \newcommand{\ajhira}[1]{\ajKakuHira{#1}} % \AddEnumerateCounter{\hira}{\ajhira}{あ} % \begin{enumerate}[label=\hira*] % \item 111 % \item 222 % \item 333 % \item 444 % \item 555 % \item 666 % \item 777 % \end{enumerate} \end{document} Any suggeestions to avoid manually add \def\@hira#1 and make good use of luatexja-otf built-in commands?
- How to prevent auto-capitalization of `author` in biblatex-philosophy?by Alexander Wittmann on February 20, 2026 at 5:44 am
Easy as that. biblatex-philosophy capitalizes all names, including the von-part, though, depending on the language, only some of them should be capitalized, and then, I want to choose it by myself. @Article{DeCampos:Unwritten, author = {de Campos, Rogério G.}, % "de" is to be omitted from sorting, should be wrtten in small letters sortname = {Campos, Rogério G.}, title = {Dotrinas I-don't-know}, langid = {brasilian}, journaltitle = {Peitho}, date = 2022, volume = 13, pages = {185-198}} versus @Article{DiBrasi:Brasilicata, author = {Di Brasi, Brasiliero}, title = {Dottrina Brasiliana}, langid = {italian}, journaltitle = {Brasilicata}, date = 2024, volume = 2, pages = {7-49}}
- Make a distorted circle a circle again, after rescaling in the `axis` environmentby Máté Wierdl on February 20, 2026 at 3:53 am
In the graph below the red "dots" get distorted due to unequal scaling. How can I make them circles again? \documentclass{article} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} \begin{tikzpicture} % Parameter: epsilon \newcommand{\eps}{0.25} % Compute intersection x-values: \pgfmathsetmacro{\xint}{acos(1 - \eps)/360} \begin{axis}[xscale=2/3, yscale=0.4, width=10cm, % chose these to keep axis height=20cm, % from automatically rescaling to a square trig format=rad, domain = -1/2:1/2, axis y line=left, axis x line=bottom, axis line style = {-}, % makes arrow heads disappear; has to come % after "axis y line" and "axis x line" xtick = {-1/2, -\xint, 0, \xint, 1/2}, xticklabels = {$-1/2$, $-\delta$, $0$, $\delta$, $1/2$}, ytick = {-1, 1-\eps, 1}, yticklabels = {$-1$, $1-\epsilon$, $1$}, ] \addplot[smooth] { cos(2*pi*x) }; \draw[dashed] (-0.5, 1 - \eps) -- (0.5, 1 - \eps); \draw[dashed] (-\xint, -1) -- (-\xint, 1 - \eps); \draw[dashed] (\xint, -1) -- (\xint, 1 - \eps); \filldraw[red] (axis cs: -\xint,1 - \eps) circle (0.5cm); \filldraw[red] (axis cs: \xint,1 - \eps) circle (0.5cm); \end{axis} \end{tikzpicture} \end{document}
- What is Tax LaTax [duplicate]by Eseoghene Precious on February 20, 2026 at 3:01 am
I am trying to draw lines around a number of nodes. I very much like the definition of \convexpath definition given here, but it is not working well on my setup (MacTex 2014 with all available updates). I tried to compile Claudio Fiandrino's first solution, but what I get is the following, which is clearly not what I should be getting. Any ideas would be much appreciated.
- Uniform sequences of mathematical dotsby Sebastiano on February 19, 2026 at 10:39 pm
When I need to write a sequence of dots without using TikZ, I often define a simple macro based on \bullet or another symbol that produces two or three dots (which they can be increase and decrease in size). However, I would like to generalize this idea so that I can obtain a sequence of n dots (horizontal, diagonal, vertical). In particular, I would like the solution I define to work well in different mathematical contexts: a sequence of dots arranged horizontally on a line, a vertical sequence for example under a brace or associated with \vdots, and even a diagonal arrangement for something like \ddots. I would also like this sequence of dots to automatically adapt to different math style sizes, meaning it should work properly in \displaystyle, \scriptstyle, \scriptscriptstyle, etc. Ideally, it should be possible to scale the symbols elegantly using packages like scalerel or equivalent techniques, so that the macro can be used in subscripts, superscripts, or expressions of different sizes without visual issues. Another requirement is that these sequences of dots should be able to be grouped in pairs, triplets, quadruplets, etc., and that such groups can be represented under a brace or curly bracket to visually highlight those groupings within the formulas. The goal is to have a parameterized macro that generates an arbitrary sequence of dots with uniform spacing and consistent behavior in various mathematical contexts, simple to use and not dependent on TikZ or other packages. Is there a well-established way to approach this problem? \documentclass{article} \usepackage{mathtools,amssymb} \newcommand{\Dots}[1]{% \mathpunct{\ifnum#1>0 \cdot\fi}% \ifnum#1>1 \mathpunct{\cdot}\fi% \ifnum#1>2 \mathpunct{\cdot}\fi% \ifnum#1>3 \mathpunct{\cdot}\fi% \ifnum#1>4 \mathpunct{\cdot}\fi% \ifnum#1>5 \mathpunct{\cdot}\fi% } \begin{document} $a\Dots{1}b$ $\Dots{2}$ $\Dots{3}$ $\Dots{4}$ $\Dots{6}$ \end{document} Something like this where the size of the bullet can be changed:
- How to draw a half‑sphere with 5‑degree lines along the x‑axis in TikZ/PGF?by AruGip on February 19, 2026 at 8:40 pm
I found this post and I'm trying to retrieve the version shown in the image below. Does anyone know how I can get that specific version? I've checked the documentation and explored the available properties, but I couldn't find anything that returns the same value shown there. Any ideas on how to achieve this?
- How to comfortably contribute to existing 3rd-party CTAN-available LaTex packages with git repositories, from my local computer?by ldfjglfkgj on February 19, 2026 at 8:29 pm
I have a full TeX Live installation with latest packages. Some packages I use have github or gitlab repositories. Sometimes I write small fixes in my preamble for some packages. I'd like to submit them back to the git repos of the packages, so that they can be merged and released on CTAN, for other to benefit from the fixes. For my own local documents I just git init and commit/push to my private repos, that's easy. But for fixes for \usepackage packages (or classes): should I just go to my /usr/local/texlive/... folder and do a git init in the package folder to be able to push to my personal remote github/gitlab account and open a pull request to the main repository? This doesn't feel right as it pollutes the TeX Live installations. I could copy-paste the whole package somewhere else and include it in my documents (for testing and directly using my changes) - but then I don't use the official version from TeX Live anymore and maybe miss other important releases. And I also have to copy-paste stuff around - uncomfortable, error-prone. How do other people comfortably contribute to 3rd party packages without polluting the local TeX installation or their own documents, and avoiding endless copy-paste situations? Disclaimer: this question is not about how to use git or upload directly to CTAN! I'd like to know how I can comfortably contribute to existing packages that have public git repositories and are maintained by someone on CTAN already.
- libertinus-otf package raising error when used in combination with amssymbby Alf on February 19, 2026 at 4:59 pm
I am using the libertinus-otf package and I prefer compiling with xelatex/lualatex. Using in addition the package amssymb raises an error though. Here is the MWE: % list every file used to standard output \listfiles \documentclass[ 12pt, a4paper, twoside, chapterprefix=true, fleqn, bibliography=totocnumbered]% {scrbook} \usepackage{iftex} \ifpdftex % true if compiling with pdfLaTeX \usepackage[T1]{fontenc} \usepackage{libertine} \else \usepackage{libertinus-otf} \fi \usepackage{amsmath} % <-- this is fine %\usepackage{amssymb} % <-- this is not working \begin{document} bla bla bla \end{document} Compiling with pdflatex is fine, compiling with xelatex/lualatex not when including the amssymb packages. The error message starts as follows: * Using libertinus math * ************************************* ) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty) ! LaTeX Error: Command `\eth' already defined. and continues with equivalent error messages for \smallsetminus, \digamma, \backepsilon The output of the file list is as follows: scrbook.cls 2023/07/07 v3.41 KOMA-Script document class (book) scrkbase.sty 2023/07/07 v3.41 KOMA-Script package (KOMA-Script-dependent basics and keyval usage) scrbase.sty 2023/07/07 v3.41 KOMA-Script package (KOMA-Script-independent basics and keyval usage) scrlfile.sty 2023/07/07 v3.41 KOMA-Script package (file load hooks) scrlfile-hook.sty 2023/07/07 v3.41 KOMA-Script package (using LaTeX hooks) scrlogo.sty 2023/07/07 v3.41 KOMA-Script package (logo) keyval.sty 2022/05/29 v1.15 key=value parser (DPC) tocbasic.sty 2023/07/07 v3.41 KOMA-Script package (handling toc-files) fleqn.clo 2016/12/29 v1.2b Standard LaTeX option (flush left equations) scrsize12pt.clo 2023/07/07 v3.41 KOMA-Script font size class option (12pt) typearea.sty 2023/07/07 v3.41 KOMA-Script package (type area) iftex.sty 2022/02/03 v1.0f TeX engine tests libertinus-otf.sty 2023/09/21 v. 0.32 (Herbert Voss) Supports libertinus fonts for lualatex and xelatex. ifxetex.sty 2019/10/25 v0.7 ifxetex legacy package. Use iftex instead. ifluatex.sty 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead. xkeyval.sty 2022/06/16 v2.9 package option processing (HA) xkeyval.tex 2014/12/03 v2.7a key=value parser (HA) textcomp.sty 2020/02/02 v2.0n Standard LaTeX package unicode-math.sty 2023/08/13 v0.8r Unicode maths in XeLaTeX and LuaLaTeX expl3.sty 2024-01-22 L3 programming layer (loader) l3backend-luatex.def 2024-01-04 L3 backend support: PDF output (LuaTeX) unicode-math-luatex.sty 2023/08/13 v0.8r Unicode maths in XeLaTeX and LuaLaTeX xparse.sty 2023-10-10 L3 Experimental document command parser l3keys2e.sty 2023-10-10 LaTeX2e option processing using LaTeX3 keys fontspec.sty 2022/01/15 v2.8a Font selection for XeLaTeX and LuaLaTeX fontspec-luatex.sty 2022/01/15 v2.8a Font selection for XeLaTeX and LuaLaTeX fontenc.sty 2021/04/29 v2.0v Standard LaTeX package fontspec.cfg fix-cm.sty 2020/11/24 v1.1t fixes to LaTeX ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file amsmath.sty 2023/05/13 v2.17o AMS math features amstext.sty 2021/08/26 v2.01 AMS text amsgen.sty 1999/11/30 v2.0 generic functions amsbsy.sty 1999/11/29 v1.2d Bold Symbols amsopn.sty 2022/04/08 v2.04 operator names lualatex-math.sty 2022/01/01 v1.12 Patches for mathematics typesetting with LuaLaTeX etoolbox.sty 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW) Any ideas how I can successfully include the amssymb package?
- Is it possible to log the contents of a box without changing pdfTeX's return value?by cfr on February 19, 2026 at 4:17 pm
Consider \documentclass{article} \begin{document} \ExplSyntaxOn \tl_set:Nn \l_tmpa_tl {abc} \tl_log:N \l_tmpa_tl \hbox_set:Nn \l_tmpa_box {abc} \box_log:N \l_tmpa_box \ExplSyntaxOff \end{document} This does exactly what I want, except that \box_log:N \l_tmpa_box changes pdfTeX's return value from 0 to 1, whereas compiling \documentclass{article} \begin{document} \ExplSyntaxOn \tl_set:Nn \l_tmpa_tl {abc} \tl_log:N \l_tmpa_tl \hbox_set:Nn \l_tmpa_box {abc} % \box_log:N \l_tmpa_box \ExplSyntaxOff \end{document} returns 0. Is it possible to log the contents of \l_tmpa_box without altering pdfTeX's exit code?
- Create a directed graphby Dimitrios ANAGNOSTOU on February 19, 2026 at 4:15 pm
I want to create the following figure. Using the following code, I managed to get something close. But I cannot figure out how to get properly the diagonal vectors without too much trial and error. Any ideas? Thanks a lot! \documentclass[a4paper,11pt]{article} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{tikz} \usetikzlibrary{positioning,arrows.meta} \begin{document} \begin{figure}[!htpb] \centering \begin{tikzpicture}[ node distance=3cm, box/.style={draw, rectangle, minimum size=1.2cm, font=\large}, arr/.style={->, >=Stealth, thick} ] % Nodes \node[box] (1) {1}; \node[box, below=of 1] (2) {2}; \node[box, right=of 1] (3) {3}; \node[box, below=of 3] (4) {4}; % Labels n_i \node[above=3mm of 1] {$n_1=3$}; \node[above=3mm of 3] {$n_3=1$}; \node[below=3mm of 2] {$n_2=2$}; \node[below=3mm of 4] {$n_4=2$}; % Horizontal 1 <-> 3 (two parallel arrows) \draw[arr] ([yshift=4pt]1.east) -- ([yshift=4pt]3.west); \draw[arr] ([yshift=-4pt]3.west) -- ([yshift=-4pt]1.east); % Vertical left \draw[arr] (1) -- (2); % Vertical right \draw[arr] (4) -- (3); % Bottom horizontal \draw[arr] (2) -- (4); % Diagonals \draw[arr] (2) -- (3); \draw[arr] ([xshift=-4pt]4.north) -- ([xshift=4pt]1.south); \draw[arr] ([xshift=-4pt]1.south) -- ([xshift=4pt]4.north); \end{tikzpicture} \end{figure} \end{document}
- I am trying to \protected@edef a bmatrix, and then I token.get_macro that token from Lua, so I can print it to the .tex at a later timeby Jasper on February 19, 2026 at 3:25 pm
I am trying to \protected@edef a bmatrix, and then I token.get_macro that token from Lua, so I can print it to the .tex at a later time. The error: WARNING: mathml missing for hash E6607B372B3A7F4DE18DB36E2B449CBD ! You can't use `\spacefactor' in math mode. \@->\spacefactor \@m {} \DocumentMetadata{ lang = en ,pdfversion = 2.0 ,pdfstandard = {UA-2} ,tagging = on } \tagpdfsetup {math/mathml/luamml/load=true} \documentclass{article} \usepackage{luacode,unicode-math,tikz} \begin{document} \makeatletter \protected@edef\COUNTDOOKU{\( \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \)} \makeatother \begin{tikzpicture} \begin{luacode*} tex.sprint( ("\\node at (0,0) {%s};") :format( token.get_macro("COUNTDOOKU") ) ) \end{luacode*} \end{tikzpicture} \end{document}
- Adjust tabularx with X columns to text widthby cis on February 19, 2026 at 2:22 pm
In the following table, I'm trying to simulate a larger table using the original settings. The p-columns (p1, p2, ..., p7) should be evenly distributed across the remaining text width. So, I've chosen \newcolumntype{Y}{>{\centering\arraybackslash}X} for them. The rest are c-columns. To me, it looks like the table fits within the text width, but I'm still getting Overfull \hbox (1.16014pt too wide). How can I fix this? \documentclass[paper=a5]{scrartcl} \usepackage[margin=14mm, showframe]{geometry} \usepackage{xcolor} \usepackage{diagbox} \usepackage{colortbl} \usepackage{tabularx} \newcolumntype{Y}{>{\centering\arraybackslash}X} \newcolumntype{K}{>{\cellcolor{pink}}c} \newcolumntype{S}{>{\cellcolor{lightgray}}c} \begin{document} \section{Tabularx with overfull hbox} \begingroup \setlength\arrayrulewidth{1pt}% test: correctness of the rules \footnotesize\sffamily % used \noindent% \begin{tabularx}{\textwidth}{c | K | *{7}{Y} | S | l } \hline $n$ & \diagbox{$k$}{$p$} & p1 & p2 & p3 & p4 & p5 & p6 & p7 & \diagbox{$p$}{$k$} \\ \hline 100 & 22 % 3 and 2 digits & 0.1111 % with leading zero & .2222 & .3333 & .4444 & .5555 & .6666 & .7777% without ~ & 22 % 2 digits \end{tabularx} \endgroup \end{document}
- how to put a character between dollarsby Jordi Pinyol on February 19, 2026 at 12:18 pm
In texmaker how can you put a character (or more) between dollars automatically, just like you can do with emphasis. For example: x=y -> select and execute a command -> $x=y$
- uneven commutative diagramby mappingmoe on February 18, 2026 at 11:33 am
I want to draw the following commutative diagram in LaTeX: I have tried tikzcd, but I think I won't work, since the rows have different size. Is there a clean way to do it? EDIT: my first approach was the following: \documentclass[a4paper]{article} \usepackage{tikz-cd} \begin{document} \begin{tikzcd} P \arrow{l}{pr} \arrow{d}{\pi} & TP \arrow{d}{T \pi}\\ I \arrow{ur}{\tilde{\gamma}} \arrow{r}{\dot{\gamma}} & M \arrow{l}{pr} & TM \end{tikzcd} \end{document}
- Generate random, unique, nonzero integersby pwesterbaan on February 17, 2026 at 8:14 pm
I've been writing some commands that I use to randomize writing exam questions. I currently have the following code for generating "variables" containing (possibly non-zero) random integers: \newcommand{\randIntLower}{1} %Lower bound on rand ints \newcommand{\randIntUpper}{5} %Upper bound on rand ints \newcommand{\randIntTemp}{} %Used for defining values in randInts \newcommand{\randInts}[2][]{% % #1 = option (default: []; Use nz for nonzero) % #2 = list of variables % Uses \randIntLower and \randIntUpper as bounds (change with renewcommand if needed) \foreach \var in {#2}{% \ifstrequal{#1}{nz}{% % nonzero method: produces +/- nonzero random integers \pgfmathparse{int(ifthenelse(rand > 0, 1, -1)*random(\randIntLower,\randIntUpper))}% \expandafter\xdef\var{\pgfmathresult}% }{% \pgfmathrandominteger{\randIntTemp}{\randIntLower}{\randIntUpper}% \expandafter\xdef\var{\randIntTemp}% }% }% } This gives me something like this: \randInts[nz]{\randOne,\randTwo,\randThree} %\randOne -> 4 %\randTwo -> -2 %\randThree -> 4 This code works well enough, with the exception that I might get repeat random numbers. I've also been running into some of the limitations of pgfmath, so I'm now trying to rewrite the above using LaTeX3 syntax (hopefully fewer issues with calculations, and optional arguments aren't as positional). My hope is to have something that behaves as such: \randInts[nz]<1>(5){randOne, randTwo, randThree} %\randOne -> 4 %\randTwo -> -2 %\randThree -> 4 \randInts*[nz]<1>(5){randOne, randTwo, randThree} %\randOne -> 4 %\randTwo -> -2 %\randThree -> 6 It grieves me to say this, but I've been trying to write this with the help of Github's CoPilot. I have been reading whatever Latex3 documentation I could find (e.g. xparse, expl3, l3kernel), but for now, this is what I've got: \ExplSyntaxOn% % Flag: whether to generate ±nonzero \bool_new:N \l__randints_nonzero_bool % Parsed bounds \int_new:N \l__randints_min_int \int_new:N \l__randints_max_int \bool_new:N \l__randints_unique_bool \clist_new:N \l__randints_used_clist \int_new:N \l__randints_range_len_int \int_new:N \l__randints_slots_int % \randInts[nz?]<min>(max){name1,name2,...} % - [nz] or [nonzero]: produce ±(magnitude), where magnitude in [min,max] % - <min> and (max) are *separate* optional delimited args; defaults are 1 and 5 % - names are bare (no leading \); defines \name globally to the drawn integer \cs_new_protected:Npn \__randints_pick_unique:nn #1 #2 { \int_set:Nn \l_tmpa_int { \int_rand:nn { #1 } { #2 } } \prg_do_while:nn { \clist_if_in:NnTF \l__randints_used_clist { \int_to_arabic:n { \l_tmpa_int } } { \prg_return_true: }{ \prg_return_false: } } { \int_set:Nn \l_tmpa_int { \int_rand:nn { #1 } { #2 } } } } \cs_new_protected:Npn \__randints_pick_unique_signed:nn #1 #2 { % Loop until we find a nonzero signed value not yet used \int_zero:N \l_tmpa_int \prg_do_while:nn { % pick magnitude \int_set:Nn \l_tmpb_int { \int_rand:nn { #1 } { #2 } } % reject zero magnitude \int_compare:nNnTF { \l_tmpb_int } = { 0 } { \prg_return_true: } { % pick sign and form signed value \int_set:Nn \l_tmpc_int { \int_rand:nn { 0 } { 1 } } \int_set:Nn \l_tmpc_int { \int_eval:n { ( \l_tmpc_int * 2 - 1 ) * \l_tmpb_int } } \clist_if_in:NnTF \l__randints_used_clist { \int_to_arabic:n { \l_tmpc_int } } { \prg_return_true: } { \int_set:Nn \l_tmpa_int { \l_tmpc_int } \prg_return_false: } } } { } } \NewDocumentCommand \randInts { s o D<>{\randIntLower} D(){\randIntUpper} m } { % Determine nonzero mode from [ #2 ] \bool_set_false:N \l__randints_nonzero_bool \IfNoValueF{#2}{ \tl_if_eq:nnT {#2} {nz} { \bool_set_true:N \l__randints_nonzero_bool } } % starred variant -> unique values (no repeats): #1 is boolean from `s` \IfBooleanTF{#1} { \bool_set_true:N \l__randints_unique_bool } { \bool_set_false:N \l__randints_unique_bool } % Normalize order (so <7>(3) becomes [3,7]) \int_set:Nn \l_tmpa_int { \int_min:nn { \l__randints_min_int } { \l__randints_max_int } } \int_set:Nn \l_tmpb_int { \int_max:nn { \l__randints_min_int } { \l__randints_max_int } } \int_set_eq:NN \l__randints_min_int \l_tmpa_int \int_set_eq:NN \l__randints_max_int \l_tmpb_int % If unique requested, check availability and clear used list \int_set:Nn \l__randints_range_len_int { \int_eval:n { \l__randints_max_int - \l__randints_min_int + 1 } } % compute available slots for uniqueness \int_set:Nn \l__randints_slots_int { \l__randints_range_len_int } \bool_if:NTF \l__randints_unique_bool { \bool_if:NTF \l__randints_nonzero_bool { \int_set:Nn \l__randints_slots_int { \int_eval:n { 2 * \l__randints_range_len_int } } \int_compare:nNnT { \l__randints_min_int } <= { 0 } { \int_compare:nNnT { \l__randints_max_int } >= { 0 } { \int_set:Nn \l__randints_slots_int { \int_eval:n { \l__randints_slots_int - 2 } } } } } { \int_set:Nn \l__randints_slots_int { \l__randints_range_len_int } } \int_compare:nNnTF { \clist_count:n {#5} } > { \l__randints_slots_int } { \PackageError{exam}{Not~enough~unique~integers}{Requested~more~unique~integers~than~available~in~range.} } { \clist_clear:N \l__randints_used_clist } } { \clist_clear:N \l__randints_used_clist } % Generate for each bare name and define \name globally \clist_map_inline:nn { #5 } { \bool_if:NTF \l__randints_nonzero_bool { % \pm nonzero: sign * magnitude (support unique/starred) \bool_if:NTF \l__randints_unique_bool { \__randints_pick_unique_signed:nn { \l__randints_min_int } { \l__randints_max_int } \cs_gset:cpn { ##1 } { \int_to_arabic:n { \l_tmpa_int } } \tl_set:Nx \l_tmpa_tl { \int_to_arabic:n { \l_tmpa_int } } \clist_put_right:Nn \l__randints_used_clist { \l_tmpa_tl } } { \cs_gset:cpn { ##1 } { \int_eval:n { ( \int_rand:nn {0}{1} * 2 - 1 ) * \int_rand:nn { \l__randints_min_int } { \l__randints_max_int } } } } } { % Plain integer in [min,max] or unique selection if starred \bool_if:NTF \l__randints_unique_bool { % pick a unique random value via recursion \__randints_pick_unique:nn { \l__randints_min_int } { \l__randints_max_int } \cs_gset:cpn { ##1 } { \int_to_arabic:n { \l_tmpa_int } } \tl_set:Nx \l_tmpa_tl { \int_to_arabic:n { \l_tmpa_int } } \clist_put_right:Nn \l__randints_used_clist { \l_tmpa_tl } } { \cs_gset:cpn { ##1 } { \int_rand:nn { \l__randints_min_int } { \l__randints_max_int } } } } } } \ExplSyntaxOff% The issues I'm running into are that prg_do_while does not actually exist. The other recommendation that Co-Pilot had was to do a recursive call, but this seems like a worse idea. So, my questions are: What is the syntax for the while loop? How should I write this code? Am I over-complicating this whole problem? EDIT Based on @David Carlisle's and @egreg's suggestions, I came up with the following code: \ExplSyntaxOn \NewDocumentCommand \newrandInts { s o D<>{\randIntLower} D(){\randIntUpper} m O{1} }{ % \randInts[nz?]<min>(max){name1,name2,...}[t] % - [nz]: produce pm(magnitude), where magnitude in [min,max] % - <min> and (max) are *separate* optional delimited args; defaults are 1 and 5 % - clist of names; defines \name globally to the drawn integer % - optional randInt multiplier t (defaults to 1) \tl_clear_new:N \l__my_number_tl \seq_clear_new:N \l_numbers_seq \tl_if_eq:nnT {#2} {nz}{ \int_step_inline:nnn {-#4}{-#3} { \seq_put_right:Nn \l_numbers_seq { \fp_eval:n{ ##1 * #6 } } } } \int_step_inline:nnn {#3}{#4} { \seq_put_right:Nn \l_numbers_seq { \fp_eval:n{ ##1 * #6 } } } \seq_shuffle:N \l_numbers_seq \clist_map_inline:nn { #5 } { \IfBooleanTF{#1}{ \seq_pop_left:NN \l_numbers_seq \l__my_number_tl \cs_gset:cpx { ##1 } { \tl_use:N \l__my_number_tl } }{ \cs_gset:cpx { ## 1 } { \seq_rand_item:N \l_numbers_seq } } } } \ExplSyntaxOff I use the code like this: \newrandInts*[nz]{a,b,c,d}[3] \a, \b, \c, \d % prints nonzero random integers between -5 and 5 % multiplied by 3 without repeats: % -3, -9, 3, -6 \newrandInts{a,b,c,d}[0.1] \a, \b, \c, \d % prints random integers between 1 and 5 % multiplied by 0.1 with repeats possible: % 0.3, 0.5, 0.4, 0.1 The multiplication by a scalar was a bit of an afterthought because my current workflow is define random integers, then scale them up.