Month
- Load a single letter from a fontby Luluio on April 20, 2025 at 8:36 am
I recently noticed that in physics gluons are usually typeset with (what I believe is called) a single-story g. The default g that comes with STIX Two Math – the math font I am using – is the double-story g and I would like to keep it that way for any variables called "g" that are not representing a gluon. My idea was to store it in a command similar to how \ell creates a script version of the letter "l" for quick access. STIX Two Math has a single-story g when applying stylistic set ss02. How could I load this g and store it in a command? A minimal example to work with should be: \documentclass{scrartcl} \usepackage{fontspec} \usepackage{mathtools} \usepackage{unicode-math} \setmainfont{STIX Two Text} \setmathfont{STIX Two Math} \begin{document} \[g\] \end{document}
- How to achieve a ragged-right text that alternates longer and shorter lines symmetrically?by TypographyConnoisseur on April 19, 2025 at 11:07 am
This was posted in reddit: https://www.reddit.com/r/typography/comments/1f9v2uc/how_is_this_kind_of_alignment_of_text_called_its/ Is there any way to achieve this in LuaLatex automatically?
- Align array elements by ones digitby Jasper on April 19, 2025 at 12:11 am
I am making arrays of numbers. How can I align them automatically by the ones digit? I understand that this won't work for arrays with math expressions in them, but I think it would be more legible for arrays which contain only decimal numbers. \documentclass{article} \begin{document} I want to align the numbers in the following array by the 1's digit, which I can't deem to accomplish using column specifiers. \[ \begin{array}{rr} -1 & 12.009 \\ 98 & -98 \end{array} \] like this, but without the phantoms: \[ \begin{array}{rr} -1 & 12.009 \\ 98 & -98\phantom{.009} \end{array} \] \end{document}
- Tipauni problem with accent marker on LaTexby Randomname on April 17, 2025 at 10:24 am
I'm using tipauni package to write IPA symbols, but there is a problem with the accent marker. I wanted to write /aˈʧitə/, but as you can see in the following image, the ' just goes above the a. Tipa doesn't give me this problem, but if possible I'd want to use tipauni. Another example: the first one is right, the second is not (I guess the ' can only go above "short" letters"): I'm using LuaLaTex, but the problem is the same with XeLaTex too. MWE to reproduce the output of the first image (run with LuaLaTeX): \documentclass{article} \usepackage{tipauni} \begin{document} \textipa{/aˈʧitə/} \end{document}
- How to use minted for highlighting two languages in one code block (LuaLaTeX)by Youra_P on April 16, 2025 at 5:50 pm
Minted loads code from a file. The file contains code in two languages TeX and Lua. I found this but it doesn't work: minted - how to highlight html also, when language "twig" is selected How to highlight both languages in one code block? MWE: % !TeX program =lualatex % !TeX encoding = utf-8 %----------------- \documentclass{article} \usepackage[newfloat]{minted} \usepackage{etoolbox} \setminted{xleftmargin=0.5cm, linenos, numbersep=5pt, breaklines, breakanywhere, frame=single, framesep=1ex, fontsize=\small} \usepackage{luacode} \begin{luacode*} -- text comment function injcount(s) local matches = {} local count = 0 local s_before_percent = s:match("^(.-)%%") or s:match("^(.-)$") if s_before_percent then s_before_percent, count = s_before_percent:gsub("put[ft]%{(.-)%}", function(match) if string.find(match, layer) then totf = totf + 1 else return match end return "" end) end return s end \end{luacode*} \makeatletter \newenvironment{code}{}{} \SetupFloatingEnvironment{listing}{name=сode} \makeatother \begin{document} Listing usage example: \begin{code} \inputminted{tex}{\jobname.tex} \end{code} \end{document}
- Adobe Acrobat not displaying inline imageby Slurp on April 16, 2025 at 2:10 pm
I've been playing around with pdfTeX primitives lately, and I'm trying to insert an inline image (of a smiley). I have the following code: \pdfcompresslevel=0 \catcode`@=11 \nopagenumbers \centerline{\hbox to100pt{\vrule width\z@ height100pt depth\z@% \pdfliteral{ .996264 0 0 .996264 0 0 cm 100 0 0 100 0 0 cm BI /BPC 8 % each value is a byte /CS /DeviceRGB % interpret colors as RGB /F [ /AHx ] % the stream is given in ASCII representing hexadecimal values /W 9 % each line is given by 9 samples /H 9 % 9 lines ID ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ff0000 ff0000 ffffff 00ff00 00ff00 ffffff 00ff00 00ff00 ffffff ff0000 ff0000 ffffff 00ff00 00ff00 ffffff 00ff00 00ff00 ffffff ff0000 ff0000 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ff0000 ff0000 ffffff 0000ff ffffff ffffff ffffff 0000ff ffffff ff0000 ff0000 ffffff ffffff 0000ff 0000ff 0000ff ffffff ffffff ff0000 ff0000 ffffff ffffff ffffff ffffff ffffff ffffff ffffff ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 ff0000 EI }\hfil}} \bye (Compiled with pdftex) As-is, no errors are reported by either ghostscript or Adobe Acrobat Pro preflight, but no image shows up on the page. But an image does show up if you use SumatraPDF (or most other viewers I assume, Acrobat is the only one which doesn't seem to show the image). Though if you run ghostscript (gs -dDEBUG file.pdf > log.txt) I noticed that nothing is printed after ID, which I assume is the issue. Another thing, if you surround the inline image with q...Q, Acrobat preflight complains about unbalanced q...Qs (too many qs). Looking at this with ghostscript, I see the following: q 0.996264 0 0 0.996264 0 0 cm 100 0 0 100 0 0 cm BI /BPC 8 /CS /DeviceRGB /F [ /AHx ] /W 9 /H 9 ID Q So (a) none of the image data is printed after ID, and (b) the Q is placed after the ID, where the image data should be. So I assume it's being read as the image data and that's why there's unbalanced q/Qs? Finally, if you remove \nopagenumbers, Acrobat preflight reports "invalid operator(s)" for the cm operator, which I was able to determine is the cm operator after the image, which places translates the CTM to place the page number. I have consulted the PDF standard, and I am unsure why this is happening. Any help would be greatly appreciated, thank you!
- Advantages and disadvantages of \text_uppercase:n vs \MakeUppercaseby David Purton on April 16, 2025 at 1:18 pm
When should I use \text_uppercase:n and when should I use \MakeUppercase? I assumed that \text_uppercase:n would always be more reliable, but I found it fails to deal with \today when a babel language is loaded in a modern way. Whereas \MakeUppercase succeeds in such a case. Consider the following MWE: \documentclass{article} \usepackage[australian, provide*=*]{babel} % \usepackage[australian]{babel} % ← works \begin{document} \MakeUppercase \today \ExplSyntaxOn \text_uppercase:n \today \end{document}
- Evaluating a functionby azetina on April 15, 2025 at 4:53 pm
Consider the following MWE: \documentclass{article} \usepackage{amsmath} \usepackage{siunitx} \ExplSyntaxOn \NewDocumentCommand{\evalfunction}{O{} O{10} m } { \num[#1]{\fp_eval:n { trunc((sqrt(#3+4)-2)/#3,#2) }} %https://tex.stackexchange.com/a/197854/10898 } \ExplSyntaxOff \begin{document} \begin{center} \renewcommand{\arraystretch}{1.2} \begin{tabular}{|r|c|} \hline $x$ & $f(x)$ \\ \hline $0.1$ & \evalfunction{0.1} \\ $0.01$ & \evalfunction{0.01} \\ $0.001$ & \evalfunction{0.001} \\ $0.0001$ & \evalfunction{0.0001} \\ \hline \end{tabular} \end{center} \end{document} The desired output is as expected. I am seeking to create a generic way of calling a function locally instead of defining within a command. Note that the command \evalfunction only works for (sqrt(#3+4)-2)/#3. I would like this to be customizable. Something like \evalfunctiondefn[abc]{(sqrt(#3+4)-2)/#3} then call \evalfunction[abc]{0.1}. Also note \evalfunction{0.01} only shows 9 decimal places instead of 10.
- PDF-Tagging and additional sub section levelsby LeO on April 14, 2025 at 8:47 am
I need addtional sub-sections for the ToC. Therefore I am using the sample code from egreg which produces \DocumentMetadata{ pdfstandard = ua-2, lang = en-GB, pdfversion = 2.0, testphase = latest, } \tagpdfsetup {math/mathml/luamml/load=true} \documentclass[a4paper]{report} \makeatletter \newcommand\level[1]{% \ifcase#1\relax\expandafter\chapter\or \expandafter\section\or \expandafter\subsection\or \expandafter\subsubsection\else \def\next{\@level{#1}}\expandafter\next \fi} \newcommand{\@level}[1]{% \@startsection{level#1} {#1} {\z@}% {-3.25ex\@plus -1ex \@minus -.2ex}% {1.5ex \@plus .2ex}% {\normalfont\normalsize\bfseries}} \newdimen\@leveldim \newdimen\@dotsdim {\normalfont\normalsize \sbox\z@{0}\global\@leveldim=\wd\z@ \sbox\z@{.}\global\@dotsdim=\wd\z@ } \newcounter{level4}[subsubsection] \@namedef{thelevel4}{\thesubsubsection.\arabic{level4}} \@namedef{level4mark}#1{} \def\l@section{\@dottedtocline{1}{0pt}{\dimexpr\@leveldim*4+\@dotsdim*1+6pt\relax}} \def\l@subsection{\@dottedtocline{2}{0pt}{\dimexpr\@leveldim*5+\@dotsdim*2+6pt\relax}} \def\l@subsubsection{\@dottedtocline{3}{0pt}{\dimexpr\@leveldim*6+\@dotsdim*3+6pt\relax}} \@namedef{l@level4}{\@dottedtocline{4}{0pt}{\dimexpr\@leveldim*7+\@dotsdim*4+6pt\relax}} \count@=4 \def\@ncp#1{\number\numexpr\count@+#1\relax} \loop\ifnum\count@<100 \begingroup\edef\x{\endgroup \noexpand\newcounter{level\@ncp{1}}[level\number\count@] \noexpand\@namedef{thelevel\@ncp{1}}{% \noexpand\@nameuse{thelevel\@ncp{0}}.\noexpand\arabic{level\@ncp{1}}} \noexpand\@namedef{level\@ncp{1}mark}####1{}% \noexpand\@namedef{l@level\@ncp{1}}% {\noexpand\@dottedtocline{\@ncp{1}}{0pt}{\the\dimexpr\@leveldim*\@ncp{5}+\@dotsdim*\@ncp{0}\relax}}}% \x \advance\count@\@ne \repeat \makeatother \setcounter{secnumdepth}{100} \setcounter{tocdepth}{100} \begin{document} \tableofcontents \level{0}{abc}\thispagestyle{empty} \level{1}{abc} \level{2}{abc} \level{3}{abc} \level{4}{abc} \level{5}{abc} \level{6}{abc} \level{7}{abc} \level{8}{abc} \level{9}{abc} \level{10}{abc} \level{11}{abc} \level{12}{abc} \end{document} When I try to compile I get basically the following error/warnings (with the same pattern for all levels) Package tagpdf Warning: tag level4 is not known Package tagpdf Warning: Empty NS Package tagpdf Warning: Parent-Child 'Sect' --> 'level4'. Depending which tool I use for checking I get either RNV Validation document.xml document.xml:352:2: error: element http://iso.org/pdf2/ssn^level4 not allowed required: after after ... </Sect> +<Sect xmlns="http://iso.org/pdf2/ssn" id="ID.067" > +<level4 id="ID.068" > +<Lbl xmlns="http://iso.org/pdf2/ssn" id="ID.069" referenced-as="5" > <?MarkedContent page="2" ?> 1.1.1.1.1 </Lbl> <?MarkedContent page="2" ?> abc </level4> </Sect> or according the VerPDF-check: A non-standard structure type is not mapped to a standard type. The semantics of such element is not defined by PDF 1.7 or PDF 2.0. Sounds like I need to map level4 to a H4 Tag - or similar. Since my TeX-coding ability is restricted I don't know first of all if my conclusions are correct and if so how to adapt the code to have correct tagging.
- plot the implicit function using Luaby 青山漫步 on April 14, 2025 at 8:23 am
I want to use the built-in Lua language in LuaLaTeX to plot the implicit function x*y^2+2*x^3*y^3-y-1=0. My idea is to plot the points within the rectangular region [−5,5]×[−5,5] that satisfy the above equation. Here is my code, but I didn't get any output. Can you tell me where I went wrong? % !TEX program = Lualatex % !Mode:: "TeX:UTF-8" \DocumentMetadata{} \documentclass[12pt]{article} \usepackage{luacode} \usepackage{tikz} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{luacode} function mefun (x,y) return x*y^2+2*x^3*y^3-y-1 end function Imfun(n) --[-5,5]*[-5,5] for i=0, n do ti=-5.0+10.0*i/n for j=0, n do tj=-5.0+10.0*j/n temp=mefun(ti,tj) if (math.abs(temp))<1e-3 then tex.print(string.format('(%2.5f, %2.5f)', ti, tj)," \\par") else break end end end end \end{luacode} \begin{document} \begin{tikzpicture} \begin{axis}[xlabel=$x$, ylabel=$y$] %\addplot coordinates{ \addplot[cyan,smooth,line width=1.0pt] coordinates{ \luadirect{ Imfun(100) } }; \end{axis} \end{tikzpicture} \end{document}
- How can I set font-specific tounicode values in LuaTeX?by cfr on April 13, 2025 at 5:21 pm
OrnementsADF puts ornaments into arbitrarily named slots in the font e.g. A, B and so on. For example, an arrowhead is in the slot named as the right square bracket. By default, then, all tounicode mappings are incorrect. For pdfTeX, this is easily, if tediously, corrected as \pdfglyphtounicode supports a per-tfm syntax. LuaTeX, however, does not. According to my (doubtless flawed) reading of the LuaTeX manual, setting tounicode values on a per-character basis, combined with a setting of tounicode to 1 for the font ought to tell LuaTeX the defined font provides Unicode mappings. At least for plain1, I can set up the font tables in a seemingly correct2 way using the define_font callback. MNWE: \directlua{ pdf.setgentounicode(1) callback.register('define_font', function (name,size) if name == "OrnementsADF" then local f = font.read_tfm('OrnementsADF.tfm',size) for i,_ in ipairs(f.characters) do f.characters[i].tounicode = "2B9E" end f.tounicode = 1 f.size = size return f else return font.read_tfm(name,size) end end) } \font\orn = OrnementsADF at 10pt \orn\char42 \directlua{ for i,j in font.each() do if j.name == 'OrnementsADF' then print(j.characters[42].tounicode) print(j.tounicode) end end } \bye The output on the console is as expected: 2B9E followed by 1. However, LuaTeX still overrides the tounicode value: copying the character from the PDF produces a square bracket rather than an arrowhead (U+2B9E). [I am not convinced this shouldn't be a different question, but, in light of feedback in comments ...] If luaotfload.sty is loaded in plain or LaTeX, it is not very easy to see how even to modify the font tables without breaking things. luaotfload.patch_font obviously can't be used and neither can define_font (that is, again without breaking stuff). Here is an MWE for LaTeX with luaotfload: \DocumentMetadata{lang=en-GB,tagging=on,pdfversion=2.0,pdfstandard=UA-2,uncompress} \documentclass{article} \font\lmr = {file:lmroman10-regular.otf} at 10pt \font\orn = OrnementsADF at 10pt \begin{document} \lmr ŵ \orn\char42 \end{document} and here's a modification which is close to the example which motivated my exploration of this particular rabbit hole. \DocumentMetadata{lang=en-GB,tagging=on,pdfversion=2.0,pdfstandard=UA-2,uncompress} \documentclass{article} \usepackage{adforn} \begin{document} ŵ \adforn{43} \end{document} What is/are the correct way/s to do this? I also have some MWEs involving luaotfload in plain, which I can post if anybody wants them. (They are a bit messier because I've been playing in that sandbox, but I can clean them up.) Note that I am aware there are many alternative Unicode fonts which could be used to provide similar symbols. I am specifically interested in ways to get correct mappings in LuaTeX for 7/8-bit symbol fonts (mostly type1 postscript), which typically assign glyphs to slots arbitrarily. pifont is probably the paradigmatic example. 1Obviously, things are more complicated in LaTeX. 2Again obviously, the mappings defined in the example are not correct as not every ornament in the font is an arrowhead. But a single Unicode point suffices for experimental purposes.
- Typesetting a matrix, using comma and semicolon as separators between entries and rows respectivelyby Name on April 11, 2025 at 9:01 am
Inspired by the question typesetting column vector, I'm working on creating a custom LaTeX command called \bbmatrix to generate a matrix surrounded by square brackets, where commas separate entries within a row and semicolons separate rows. Here's an example of what I want to achieve: Input: \bbmatrix{a,b;c,d} Equivalent to: \begin{bmatrix} a & b \\ c & d \end{bmatrix} where the bmatrix environment is defined by the amsmath package. Similarly, for more rows: Input: \bbmatrix{a,b;c,d;e,f} Equivalent to: \begin{bmatrix} a & b \\ c & d \\ e & f \end{bmatrix} etc A full but nonworking example (as \bbmatrix isn't defined yet): \documentclass{article} \usepackage{amsmath} % for 'bmatrix' environment \begin{document} \[ \bbmatrix{a,b;c,d} \quad \bbmatrix{a,b;c,d;e,f} \quad \bbmatrix{a,b,c,d} % a row vector \quad \bbmatrix{a;b;c;d} % a column vector \] \end{document} Motivation When writing a document, occasionally inserting a matrix like this: \begin{bmatrix} a & b \\ c & d \\ e & f \end{bmatrix} is manageable. However, if your document contains many matrices throughout, typing them out can become very time-consuming. One challenge is that on many keyboards, the ampersand (&) requires pressing the Shift key, which slows down typing. Additionally, typing double backslashes (\\) can further slow you down. In contrast, commas and semicolons are easily accessible on most keyboards. Therefore, using a command like \bbmatrix{a,b;c,d} could significantly speed up the process, saving you a lot of time when working with multiple matrices.
- how to draw mutually tangent circlesby underflow on April 10, 2025 at 7:18 pm
I need to draw two concentric circles plus additional circles that the mutually tangent, like this: I tried using \draw (0,0) arc [radius=1, start angle=-30, end angle= 60]; \draw (0,0) arc [radius=3, start angle=-30, end angle= 60]; to draw the concentric arcs, but it seems that the "(0,0)" specify the starting point and not the center of the arc. Eventually I hacked together an ad hoc tikz code to make this picture (see below), but I wonder if there is a more standard/non-adhoc ways to do this? E.g. is there a way to get tizk to polar polar graphs directly? BONUS Q: How do I color the wedge bounded by the two line segments and the outer arc? Thanks! My hacky code that produces this picture: \documentclass{amsart} \usepackage{tikz} \begin{document} \begin{tikzpicture} \draw [ultra thick, domain=0.0:2] plot(\x, { sqrt(4-\x*\x)}); \draw [ultra thick, domain=1.7:2] plot(\x, {-sqrt(4-\x*\x)}); \draw [ultra thick, domain=-0.3:0.6] plot(\x, { sqrt(0.36-\x*\x)}); \draw [ultra thick, domain= 0.4:0.6] plot(\x, {-sqrt(0.36-\x*\x)}); \draw [ultra thick] (1.3, 0) circle [radius=0.7]; \draw [ultra thick] (0.5, 1.2) circle [radius=0.7]; \draw [thick] (0,0) -- (2,0); \draw [thick] (0,0) -- (0.76,1.85); \end{tikzpicture} \end{document}
- \big with or without unicode-mathby Paul Gaborit on April 10, 2025 at 3:33 pm
Using the following code (and lualatex): \documentclass{article} %\usepackage{unicode-math} \pagestyle{empty} \begin{document} $\Bigg(\bigg(\Big(\big(($ \end{document} We obtain: (\usepackage{unicode-math} commented) (\usepackage{unicode-math} uncommented) With unicode-math, the difference between \big( and ( becomes visually imperceptible. How do I get visible size changes again?
- Can luatex parse log file at end, similar to grep, but without shell escape?by rallg on April 8, 2025 at 1:29 am
The Missing character message in Terminal is understandable to those of us who understand things. But it is a bit complex, to those of us who merely write (instead of coding). Worse, if \tracinglostchars=3 to stop there, and the user types h for help, the Terminal suggests asking a human. Being human (not yet replaced by AI), I would like to help by re-writing how the Missing character error is displayed. But I asked about that before, and it cannot be done (because the message comes from binaries). Still being human, I would like to try something else. This approach, if it can be done without too much code, would use \tracinglostchars=2 to detect them, without stopping. At the end, luatex would read the log file, and search for Missing character. If detected, the Terminal would get nasty. (I already know how to get nasty.) MWE: \usepackage{fontspec} \tracinglostchars=2 % For this situation, not reporting an error during typesetting. \AddToHook{enddocument/end}{% % Lua function that reads the log file, looking for `Missing character'. % Does not need more information. Simply return true if found, else false. % Then the Terminal will display a message, such as "BAD DOC! NO DONUTS!" }% \begin{document} Foo ☹ bar. % Frowny face, not in lmr. \end{document} The concept is similar to what grep does, but I cannot use --shell-escape. Possible? Useful? Why I ask: I use custom fonts with intentionally limited character set. Other users may not grasp what is happening, if they try characters that "should be there" but are not.
- Challenge: Show us your best tariff tablesby mickep on April 4, 2025 at 11:07 am
There are too few silly "contests" here nowadays, and I really think we could need a laugh. We have likely all seen the beautiful tariff table the other day. In case somebody missed it, here is one example image of it: The challenge here is to show off, in any TeX dialect, and make your own tariff table. The sillier the better. But also fun if there is something to learn, TeX-wise, by studying your solution. I will make this post community. Have fun!
- Why do \left( and \right) not produce same-sized parantheses here?by Márton Horváth on April 2, 2025 at 5:39 pm
Given the equation below, I bumped into an issue that for the first pair of parentheses in the denominator, \left( and \right) produced smaller parentheses compared to the second pair of parentheses (i.e., no syntax error). See the figure below illustrating the problem. \begin{equation} P_{n+1} - P_n = rCP \phantom{l} \frac{\frac{t_n-t_{n+1}}{\tau}}{\left(1+ \frac{t_n}{\tau}\right) \left(1+ \frac{t_{n+1}}{\tau}\right)}. \end{equation} However, if I set the size of the parentheses in question explicitly using \Big( and \Big), I could overcome the issue. \begin{equation} P_{n+1} - P_n = rCP \phantom{l} \frac{\frac{t_n-t_{n+1}}{\tau}}{\Big(1+ \frac{t_n}{\tau}\Big) \left(1+ \frac{t_{n+1}}{\tau}\right)}. \end{equation} I found this really strange and was wondering: what is the reason behind this?
- Abbreviations with letters over symbolsby Andrew Stacey on April 1, 2025 at 6:57 pm
When writing mathematical notes, I often abbreviate common words such as "theorem", "equation", and the like. My usual method (in handwriting) is to write "thm", but with the "m" slightly superscripted and with a line underneath. I did the above using TikZ to position the m and underline it: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \node[inner sep=0pt, outer sep=0pt] (a) {th}; \node[above right,font=\tiny, inner sep=0pt, outer sep=0pt] (m) at (a.mid east) {m}; \draw ([yshift=-.2ex]m.south west) -- ([yshift=-.2ex]m.south east); \end{tikzpicture} \end{document} This feels like overkill, but I can't find a way to do this without invoking math mode (such as \stackrel or the accents package). The underline could be a symbol, such as a tilde, so it doesn't have to be a drawn object. Indeed, I'm looking for a general way to do this - the prompt for this was to typeset a combination of a letter above a dot (but with the letter slightly smaller, so it's not just an accent) as below:
- hyperref does not jump correctly to the labeled proof environmentby Akira on April 1, 2025 at 1:36 pm
I have a tex file \documentclass{article} \usepackage{amsthm} \usepackage[hypertexnames=false]{hyperref} \hypersetup{ colorlinks=true, linkcolor=blue, } \begin{document} \begin{equation} A = B . \end{equation} \begin{proof} \label{prf} If A then B. \end{proof} We want to refer to \hyperref[prf]{this proof}. \end{document} When I lick on this proof on the PDF, the PDF viewer jumps to A=B. Could you elaborate on this issue and how to solve it?
- How can I write an equation nicely, without unnecessary spaces? [duplicate]by Youra_P on March 30, 2025 at 4:46 pm
How can I write an equation nicely, without unnecessary spaces? MWE: % !TeX program = pdflatex \documentclass{article} \usepackage{amsmath, amssymb} \begin{document} \begin{equation}\label{eq:w2} w_2 = \left( \prod_{v^d \in V^d}{ \left( \sum_{f^d \in F^d, gV(f^d) \cap \{ v^d \} \neq \emptyset }{TFCount(f^d)} \right) } \right)^{\frac{1}{mv}} \rightarrow \min \, . \end{equation} \end{document}
- Defining a macro that needs to test the inputby Knudsen on March 30, 2025 at 12:27 pm
How can I define a new \bar command that would allow me to finelly adjust it differently for every character (position, thichness, ...)? Something like the proto-code \documentclass{report} \newcommand{\mybar}[1]{ if #1 in {a,b,c,d,e} then \mybar = ... if #1 in {f,i,j,l,t} then \mybar = ... if #1 in {A,I,J,} then \mybar = ... if #1 in {M,W} then \mybar = ... } \begin{document} This is a bar: $\mybar{a}$. \end{document} that would act only on single-characters a-z, A-Z, and assuming that I already know the definition for each group of characters.
- Fill area between hyperbola and line with pgfplotsby Magnivul on March 29, 2025 at 7:25 pm
This is my first time using TikZ and pgfplots, and I've been trying, to no avail, to color the area enclosed by the graphs of the functions x^2 - y^2 = 9 and y = 4x - 16. My problem is that fillbetween either fills area that isn't enclosed, or doesn't fill area that is enclosed, depending on the domain I try to clip it to. Currently what I've got looks like this: And I want the area at the bottom that is not enclosed by the graphs not to be colored. Any help would be much appreciated. Here is the TeX code: \documentclass{standalone} \usepackage[svgnames]{xcolor} \usepackage{tikz,pgfplots,tkz-euclide,tkz-graph} \pgfplotsset{compat=1.18} \usetikzlibrary{calc,shapes,angles,patterns,shadows,arrows.meta} \usepgfplotslibrary{statistics,fillbetween} \pgfplotsset{ standard/.style={ axis line style = thick, trig format=rad, axis x line=middle, axis y line=middle, xlabel = {\( x \)}, ylabel = {\( y \)}, every axis x label/.style={at={(current axis.right of origin)},anchor=west}, every axis y label/.style={at={(current axis.above origin)},anchor=south} } } \begin{document} \begin{tikzpicture} \begin{axis}[standard, scale only axis, ticklabel style = {font = \tiny}, grid = both, grid style = {dashed, gray!50}, xmin = -1, xmax = 7, ymin = -3, ymax = 5, xtick = {0,...,6}, ytick = {-2,-1,..., 4}, domain = 3:7, samples = 1000] \addplot[name path = f, line width = 0.5mm, Teal]{4*x - 16}; \addplot[name path = g1, line width = 0.5mm, MediumPurple]{sqrt(x^2 - 9)}; \addplot[name path = g2, line width = 0.5mm, MediumPurple]{-sqrt(x^2 - 9)}; \node[Teal] at (5.8, 1.5) {\( y = 4x - 16 \)}; \node[MediumPurple] at (2.2, 2.5) {\( x^2 - y^2 = 9 \)}; \addplot[SteelBlue!50, opacity = 0.8] fill between [of = f and g1, soft clip = {domain = 3:5}]; \end{axis} \end{tikzpicture} \end{document}
- How to use scope to reproduce a figure by symmetry or rotationby Kawahiem on March 28, 2025 at 10:51 am
I'm trying to draw this with LaTeX : and so far I've done this : Here's the code for that image : \documentclass[10pt, a4paper]{article} \usepackage{tikz} \usepackage{tkz-euclide} \begin{document} \begin{tikzpicture}[scale = 0.7] \tkzDefPoints{0/0/D, 16/0/C, 16/16/B, 0/16/A, 8/8/O} \foreach \i/\j/\k in {A/B/I, B/C/J, C/D/K, D/A/L}{\tkzDefMidPoint(\i,\j) \tkzGetPoint{\k}} \draw (A)--(B)--(C)--(D)--cycle (A)--(C) (B)--(D) (I)--(K) (J)--(L); \foreach \i/\j in {0.125/1, 0.25/2, 0.375/3, 0.5/4, 0.625/5, 0.75/6, 0.875/7} { \tkzDefPointsBy[homothety=center A ratio \i](I){A\j} \tkzDefPointsBy[homothety=center O ratio \i](I){I\j} \draw (A\j)--(I\j); \tkzDefPointsBy[homothety=center A ratio \i](O){O\j} \draw (A\j)--(O\j); } \foreach \i in {1,...,7}{ \tkzLabelPoint[above](A\i){$A_{\i}$}} \tkzLabelPoints[above](A,I,B) \tkzLabelPoints[below](D,K,C) \tkzLabelPoints[right](J) \tkzLabelPoints[left](L) \tkzLabelPoints[below right](O) \end{tikzpicture} \end{document} I suppose it could be better but that's not the point. I'm trying to use what I've already done to fill the square using symmetry or rotation. I feel like the scope environment would be suited to do this... but I can't get it to work. I read a lot of topics on how to use scope, including this one : rotate a scope with named coordinates defined outside the scope but to no avail. Could someone show me how to do this ? And later on, I'll probably ask a question on how to color the figure.
- New official LaTeX3 packages like ltpropertiesby Gargantuar on March 28, 2025 at 2:33 am
Is there a list of new LaTeX3 packages (with documentation) useful for package/class authors? For example, the ltproperties package seems useful which is, however, not listed on the official documentation page of the LaTeX project. On the other hand, ltmarks is listed.
- unicode-math large misplaces prime signby juanfal on March 28, 2025 at 12:40 am
The change of font size misplaces the prime sign with kp-fonts \documentclass{article} \usepackage{kpfonts} \begin{document} \tiny r' \footnotesize r' \normalsize r' \large r' \Large r' \huge r' \Huge r' \tiny $r'$ \footnotesize $r'$ \normalsize $r'$ \large $r'$ \Large $r'$ \huge $r'$ \Huge $r'$ \end{document} Edit [cfr] The problem is reproducible with just unicode-math and either LuaTeX or XeTeX. For the default Latin Modern, for example, \documentclass{article} \usepackage{unicode-math} \begin{document} \tiny r' \footnotesize r' \normalsize r' \large r' \Large r' \huge r' \Huge r' \tiny $r'$ \footnotesize $r'$ \normalsize $r'$ \large $r'$ \Large $r'$ \huge $r'$ \Huge $r'$ \end{document} With xcharter-otf, which I'm told shows the problem is not (or, at least, certainly not only) use of the minute at larger sizes rather than the appropriate stylistic variant: The problem is reproducible in at least TL 2025 and 2024.
- Itemize and babel cause error in TeXLive 2025by Sean Emerich on March 27, 2025 at 7:11 am
I recently upgraded to TeXLive 2025, and a piece of code where I used babel inside of an itemize list is now breaking. Here is a MWE that works before the update, but not on TeXLive 2025. Note that if the \foreignlanguage piece isn't in an itemize list, no error occurs. \documentclass{article} \usepackage{babel} \babelfont[chinese-simplified]{rm}{Kaiti SC} \begin{document} \begin{itemize} \item \foreignlanguage{chinese-simplified}{你好} \end{itemize} \end{document} where Kaiti SC is just a Chinese font installed on my computer. LuaLaTeX gives the following error: (/usr/local/texlive/2025/texmf-dist/tex/generic/babel/locale/zh/babel-chinese-s implified.tex)[\directlua]:1: unexpected symbol near '\'. \bbl@cjkintraspace ...d lang.hyphenate(head) end } \bbl@luahyphenate l.8 ...foreignlanguage{chinese-simplified}{你好} ? [\directlua]:1: attempt to index a nil value (field 'cjk_characters') stack traceback: [\directlua]:1: in main chunk. <argument> ...( cs == 'op') and 'cl' or 'op' end } l.8 ...foreignlanguage{chinese-simplified}{你好} Any ideas why this might be happening? Thanks in advance.
- expl3 - define custom argument type which processes two undelimited TeX arguments and returns one undelimited TeX argumentby Ulrich Diez on March 26, 2025 at 11:46 pm
For the sake of having fun I tried to implement expl3 argument types s and S which process two brace groups/two undelimited TeX arguments so that the first undelimited TeX argument/brace group holds an integer expression denoting how many times the leading token of the second undelimited TeX argument/brace group is to be hit by \expandafter. s‑type arguments return the result nested in a single brace group. S‑type arguments return the result without braces and are to be used when the result is to consist of a single token which is further processed as an N‑type argument. I.e., when providing an s‑type‑ or an S‑type‑argument, the syntax is: {⟨balanced expl3 integer expression⟩}{⟨balanced text⟩}. (I chose the letters s and S as names of the argument types, because these letters can be seen as an abbreviation for ""trigger several expansion steps on the leading token". Like with argument type N versus argument type n, the uppercase S indicates that the result of pre-processing is to be a single token, not some constellation of tokens within a brace group. If there is already some deprecated expl3‑argument type s or S, then please forgive me.) It sort of works. But, instead of defining a command for just doing a sequence of calls to internal functions \::N \::⟨argument specifier⟩…\::⟨argument specifier⟩ \::: {} , the commands \exp_args_generate:n and \cs_generate_variant:Nn define commands \exp_args:N⟨argument specifiers⟩ where each argument specifier is assumed to denote a single undelimited TeX argument, i.e., a single token or a single brace group, and where \tex_expanded:D and a lot of \exp_not:⟨argument specifier⟩ is used. Seems there is the restriction that (except with the p‑type argument specifier and probably w‑type argument specifier) an expl3 argument specified by an expl3 argument specifier must consist of a single undelimited TeX argument, i.e., of a single token or of a single brace group. In order to judge whether delving into the implementation of \exp_args_generate:n and \cs_generate_variant:Nn might be a fruitful experience, I have some questions: Why is that restriction in the design? Has some discussion about that pros and cons of that restriction taken place which is available to the public? In case you are interested in TeXnical details of my playing around, the following exhibits what I have tried so far, but please be aware that the question actually is not about how to implement specifying an amount of expansion steps that are to be applied on the first token of a TeX argument but is about the pros and cons of restricting expl3 argument types to denote arguments that consist of a single token/a single brace group only, i.e., that consist of a single TeX argument only. The matter of specifying an amount of expansion steps that are to be applied on the first token of a TeX argument actually is mentioned for illustrative purposes only and the following code actually is provided for those who want to see some code/MRE/MCVE/MWE with every question. You can easily obey the restriction of expl3 argument types denoting arguments that consist of a single TeX argument only, by wrapping components of s‑type‑/S‑type‑argument into an additional pair of curly braces so that the syntax becomes: {{⟨balanced expl3 integer expression⟩}{⟨balanced text⟩}}. For those who are interested in the matter of specifying an amount of expansion steps that are to be applied on the first token of a TeX argument let's mention that this matter has been discussed many times in many places. For example there has been discussion about routines \romannumeal\expandtimes{⟨TeX number quantity⟩}⟨tokens⟩ and the like at the usenet newsgroup comp.text.tex from October 29, 2009 to November 9, 2009 under the subject "expand in macro", google-groups-urls of some postings of that discussion: https://groups.google.com/g/comp.text.tex/c/DUHxnOlKrII/m/iVP7-rZKEFMJ https://groups.google.com/g/comp.text.tex/c/DUHxnOlKrII/m/kaztADyofNwJ from December 11, 2010 to December 12, 2010 under the subject "Searching means of avoiding \expandafter in LaTeX2e-macros", google-groups-urls of some postings of that discussion: https://groups.google.com/g/comp.text.tex/c/mFOSIsEfBg8/m/YhJhKYfxR0cJ from March 28, 2011 to April 02, 2011 under the subject "Nice space token...", google-groups-urls of some postings of that discussion: https://groups.google.com/g/comp.text.tex/c/D4YbNKsh77s/m/hsUnPYHVuO8J https://groups.google.com/g/comp.text.tex/c/D4YbNKsh77s/m/8Wnq3Tj-2AAJ (Some of the people who took part in these discussions are no longer with us and I miss them deeply.) First I defined some dummy commands for exhibiting the result of the expansion cascade: %%====================================================================== % Some dummy-commands for exhibiting the result of the expansion-cascade: %%====================================================================== \def\a{\b} \def\b{\c} \def\c{\d} \def\d{\e} \def\e{\f} \def\f{g} Then I implemented internal functions \::s and \::S for s‑type‑ and S‑type‑arguments: \ExplSyntaxOn %%====================================================================== %% Implementation of s's and S's internal functions \::s and \::S %%====================================================================== %% \exp:w \Expandtimes{<integer expression evaluating to value K>}<tokens> %% or -- as long as expl3 defines \exp:w equal to \romannumeral -- %% \romannumeral\Expandtimes{<integer expression evaluating to value K>}<tokens> %% %% -> the first token of <tokens> is hit K times by %% \expandafter/\exp_after:wN . %%---------------------------------------------------------------------- \cs_new_nopar:Npn \Expandtimes #1 { \int_compare:nNnTF { #1 }{>}{0} { \exp_args:No \__MYSTUFF_exp_IntersperseWithExpafterwNLoop:nn {\int_value:w \int_eval:n{ #1-1 }}{} } { \exp_end: } } \cs_new_nopar:Npn \__MYSTUFF_exp_IntersperseWithExpafterwNLoop:nn #1#2 { \tl_if_blank:nTF { #1 } { \exp_after:wN \Expandtimes \exp_after:wN {#2\exp_after:wN} } { \exp_args:No \__MYSTUFF_exp_movehead:nnn {\tl_head:w #1{} \q_stop}{#1}{#2} } } \cs_new_nopar:Npn \__MYSTUFF_exp_movehead:nnn #1#2#3 { \exp_args:No \__MYSTUFF_exp_IntersperseWithExpafterwNLoop:nn {\use_i:nn{}#2}{#3\exp_after:wN#1} } %%---------------------------------------------------------------------- %% Argument-types based on \Expandtimes : %%---------------------------------------------------------------------- \cs_new:Npn \::s #1 \::: #2#3#4 { \exp_args:No \__exp_arg_next:nnn {\exp:w \Expandtimes{#3}#4}{#1}{#2} } \cs_new:Npn \::S #1 \::: #2#3#4 { \exp_last_unbraced:No \__exp_arg_next:Nnn {\exp:w \Expandtimes{#3}#4}{#1}{#2} } Then I defined some commands where s‑type‑ and S‑type‑arguments are grabbed by calling the internal functions directly—these work out: %%====================================================================== %% Some commands where s- and S-type-arguments are grabbed by calling %% the internal functions directly; TESE WORK OUT: %%====================================================================== \cs_new:Npn \MYSTUFF_exp_times:Ns { \::N \::s \::: {} } \cs_new:Npn \MYSTUFF_MYSTUFF_exp_times:Nnfso { \::N \::n \::f \::s \::o \::: {} } \cs_new:Npn \StringifyFourArguments #1 #2 #3 #4 { \tl_to_str:n {{#1}{#2}{#3}{#4}} } \cs_new:Npn \StringifyStopmarkerDelimited #1 \stopmarker { \tl_to_str:n {#1} } Then I tried to hook into \cs_generate_variant:Nn and \exp_args_generate:n to make sure that with these commands s and S are accepted as argument specifiers: I tried to look at source3.pdf to learn how \exp_args_generate:n and \cs_generate_variant:Nn are defined, but the commenting of the implementation is so inscrutable that I could spend weeks trying to figure out what is going on. %%====================================================================== %% Hooking into \cs_generate_variant:Nn and into \exp_args_generate:n : %% %% !!! THIS HOOKING IS NOT SUFFICIENT FOR HAVING \cs_generate_variant:Nn %% AND \exp_args_generate:n WORK OUT!!! %%====================================================================== %\cs_new:Npn \exp_not:s { \::s \::: {\exp_not:n } } %\cs_new:Npn \exp_not:S { \::S \::: {\exp_not:N } } \cs_set_protected:Npn \exp_args_generate:n #1 { \exp_args:No \clist_map_inline:nn { \tl_to_str:n {#1} } { \str_map_inline:nn {##1} { % Add s and S to the list of argument tyes that are allowed with `\exp_args_generate:n`. \str_if_in:nnF { NnpcofeVvxsS } {####1} { \__kernel_msg_error:nnnn { kernel } { invalid-exp-args } {####1} {##1} \str_map_break:n { \use_none:nn } } } \__cs_generate_internal_variant:n {##1} } } % After expansion S is N and s is n, so let's add that to % \__cs_generate_variant_loop_base:N : \cs_set:Npn \__cs_generate_variant_loop_base:N #1 { \if:w c #1 N \else: \if:w o #1 n \else: \if:w V #1 n \else: \if:w v #1 n \else: \if:w f #1 n \else: \if:w e #1 n \else: \if:w x #1 n \else: \if:w n #1 n \else: \if:w N #1 N \else: \if:w S #1 N \else: \if:w s #1 n \else: \scan_stop: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: } Then I tested the commands where s‑type‑ and S‑type‑arguments are grabbed by calling the internal functions directly: \tex_message:D { Testing~the~commands~where~s-~and~S-type-arguments~are~grabbed~% by~calling~the~internal~functions~directly:^^J} \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {0}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {0}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {1}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {1}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {2}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {2}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {3}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {3}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {4}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {4}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {5}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {5}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {6}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {6}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {0}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {0}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {1}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {1}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {2}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {2}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {3}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {3}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {4}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {4}{\c} {\d}^^J } Testing the commands where internal functions are called directly works out and produces the following output into the .log-file and onto the console: Testing the commands where s- and S-type-arguments are grabbed by calling the i nternal functions directly: \MYSTUFF_exp_times:Ns \tl_to_str:n {0}{\a } yields: \a \MYSTUFF_exp_times:Ns \tl_to_str:n {1}{\a } yields: \b \MYSTUFF_exp_times:Ns \tl_to_str:n {2}{\a } yields: \c \MYSTUFF_exp_times:Ns \tl_to_str:n {3}{\a } yields: \d \MYSTUFF_exp_times:Ns \tl_to_str:n {4}{\a } yields: \e \MYSTUFF_exp_times:Ns \tl_to_str:n {5}{\a } yields: \f \MYSTUFF_exp_times:Ns \tl_to_str:n {6}{\a } yields: g \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{0}{\c }{\d } yields: {\a }{g}{\c }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{1}{\c }{\d } yields: {\a }{g}{\d }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{2}{\c }{\d } yields: {\a }{g}{\e }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{3}{\c }{\d } yields: {\a }{g}{\f }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{4}{\c }{\d } yields: {\a }{g}{g}{\e } Then I defined a base function \MYSTUFF_BaseCommand:nNnN and—via \cs_generate_variant:Nn—a variant \MYSTUFF_BaseCommand:sSsS: \cs_new:Nn \MYSTUFF_BaseCommand:nNnN {\tl_to_str:n {{#1}#2{#3}#4}} \cs_generate_variant:Nn \MYSTUFF_BaseCommand:nNnN {sSsS} Then I produced commands for displaying the meaning of the variant produced this way: \tex_message:D {Meaning~of~\token_to_str:N\MYSTUFF_BaseCommand:sSsS\space is:^^J\cs_meaning:N\MYSTUFF_BaseCommand:sSsS^^J} \tex_message:D {Meaning~of~\token_to_str:N\exp_args:NsSsS\space is:^^J\cs_meaning:N\exp_args:NsSsS^^J} \tex_message:D {Meaning~of~\token_to_str:N\exp_not:s\space is:^^J\cs_meaning:N\exp_not:s^^J} \tex_message:D {Meaning~of~\token_to_str:N\exp_not:S\space is:^^J\cs_meaning:N\exp_not:S^^J} These commands produce the following output into the .log-file and onto the console: Meaning of \MYSTUFF_BaseCommand:sSsS is: \long macro:->\exp_args:NsSsS \MYSTUFF_BaseCommand:nNnN Meaning of \exp_args:NsSsS is: \long macro:#1#2#3#4#5->\tex_expanded:D {\exp_not:N #1{\exp_not:s {#2}}{\exp_no t:S {#3}}{\exp_not:s {#4}}{\exp_not:S {#5}}} Meaning of \exp_not:s is: undefined Meaning of \exp_not:S is: undefined This output in turn reveals that producing s‑type‑ or S‑type‑variants this way is problematic because it does not work out. One reason why with these meanings things do not work out is that \exp_not:s and \exp_not:S are not defined. But even if you would define them, e.g., as \cs_new:Npn \exp_not:s { \::s \::: {\exp_not:n } } \cs_new:Npn \exp_not:S { \::S \::: {\exp_not:N } } , things would still not work out. This is because \cs_generate_variant:Nn, like \exp_args_generate:n {sSsS} would do, defines a command \exp_args:NsSsS which for each of the argument specifiers grabs a single undelimited TeX argument (and thus grabs five undelimited TeX arguments) and does \tex_expanded:D, applying \exp_not:N/\exp_not:s/\exp_not:S‑trickery to each of the five undelimited TeX arguments while arguments of s‑type‑ and S‑type‑arguments are to consist of two brace groups/two undelimited TeX arguments and not just one. However, you can rectify things by defining a command \exp_args:NsSsS by hand which just calls internal functions for doing the argument-grabbing: \cs_set:Npn \exp_args:NsSsS {\::N \::s \::S \::s \::S \::: {} } With this definition the command \tex_message:D {\MYSTUFF_BaseCommand:sSsS {0}{\a} {1}{\a} {2}{\a} {3}{\a}^^J} produces the following output into the .log-file and onto the console: {\a }\b {\c }\d With this definition the command \tex_message:D {\exp_args:NsSsS \StringifyStopmarkerDelimited {0}{\a} {1}{\a} {2}{\a} {3}{\a} \stopmarker^^J} produces the following output into the .log-file and onto the console: {\a }\b {\c }\d Defining a command \MYSTUFF_BaseCommand:sSsS by hand via internal functions instead of using \cs_generate_variant:Nn also works out: \cs_gset:Npn \MYSTUFF_BaseCommand:sSsS { \::s \::S \::s \::S \::: {\MYSTUFF_BaseCommand:nNnN} } \tex_message:D { \MYSTUFF_BaseCommand:sSsS {0}{\a} {1}{\a} {2}{\a} {3}{\a} } This produces the following output on console and .log-file: {\a }\b {\c }\d There still is the need of ending things: \stop For those who want a complete minimal reproducible example (MRE)/minimal complete verifiable example (MCVE)/minimal working example (MWE) instead of having things split across snippets of code that are interspersed with commenting: %%====================================================================== % Some dummy-commands for exhibiting the result of the expansion-cascade: %%====================================================================== \def\a{\b} \def\b{\c} \def\c{\d} \def\d{\e} \def\e{\f} \def\f{g} \ExplSyntaxOn %%====================================================================== %% Implementation of s's and S's internal functions \::s and \::S %%====================================================================== %% \exp:w \Expandtimes{<integer expression evaluating to value K>}<tokens> %% or -- as long as expl3 defines \exp:w equal to \romannumeral -- %% \romannumeral\Expandtimes{<integer expression evaluating to value K>}<tokens> %% %% -> the first token of <tokens> is hit K times by %% \expandafter/\exp_after:wN . %%---------------------------------------------------------------------- \cs_new_nopar:Npn \Expandtimes #1 { \int_compare:nNnTF { #1 }{>}{0} { \exp_args:No \__MYSTUFF_exp_IntersperseWithExpafterwNLoop:nn {\int_value:w \int_eval:n{ #1-1 }}{} } { \exp_end: } } \cs_new_nopar:Npn \__MYSTUFF_exp_IntersperseWithExpafterwNLoop:nn #1#2 { \tl_if_blank:nTF { #1 } { \exp_after:wN \Expandtimes \exp_after:wN {#2\exp_after:wN} } { \exp_args:No \__MYSTUFF_exp_movehead:nnn {\tl_head:w #1{} \q_stop}{#1}{#2} } } \cs_new_nopar:Npn \__MYSTUFF_exp_movehead:nnn #1#2#3 { \exp_args:No \__MYSTUFF_exp_IntersperseWithExpafterwNLoop:nn {\use_i:nn{}#2}{#3\exp_after:wN#1} } %%---------------------------------------------------------------------- %% Argument-types based on \Expandtimes : %%---------------------------------------------------------------------- \cs_new:Npn \::s #1 \::: #2#3#4 { \exp_args:No \__exp_arg_next:nnn {\exp:w \Expandtimes{#3}#4}{#1}{#2} } \cs_new:Npn \::S #1 \::: #2#3#4 { \exp_last_unbraced:No \__exp_arg_next:Nnn {\exp:w \Expandtimes{#3}#4}{#1}{#2} } %%====================================================================== %% Some commands where s- and S-type-arguments are grabbed by calling %% the internal functions directly; TESE WORK OUT: %%====================================================================== \cs_new:Npn \MYSTUFF_exp_times:Ns { \::N \::s \::: {} } \cs_new:Npn \MYSTUFF_exp_times:Nnfso { \::N \::n \::f \::s \::o \::: {} } \cs_new:Npn \StringifyFourArguments #1 #2 #3 #4 { \tl_to_str:n {{#1}{#2}{#3}{#4}} } \cs_new:Npn \StringifyStopmarkerDelimited #1 \stopmarker { \tl_to_str:n {#1} } %%====================================================================== %% Hooking into \cs_generate_variant:Nn and into \exp_args_generate:n : %% %% !!! THIS HOOKING IS NOT SUFFICIENT FOR HAVING \cs_generate_variant:Nn %% AND \exp_args_generate:n WORK OUT!!! %%====================================================================== %\cs_new:Npn \exp_not:s { \::s \::: {\exp_not:n } } %\cs_new:Npn \exp_not:S { \::S \::: {\exp_not:N } } \cs_set_protected:Npn \exp_args_generate:n #1 { \exp_args:No \clist_map_inline:nn { \tl_to_str:n {#1} } { \str_map_inline:nn {##1} { % Add s and S to the list of argument tyes that are allowed with `\exp_args_generate:n`. \str_if_in:nnF { NnpcofeVvxsS } {####1} { \__kernel_msg_error:nnnn { kernel } { invalid-exp-args } {####1} {##1} \str_map_break:n { \use_none:nn } } } \__cs_generate_internal_variant:n {##1} } } % After expansion S is N and s is n, so let's add that to % \__cs_generate_variant_loop_base:N : \cs_set:Npn \__cs_generate_variant_loop_base:N #1 { \if:w c #1 N \else: \if:w o #1 n \else: \if:w V #1 n \else: \if:w v #1 n \else: \if:w f #1 n \else: \if:w e #1 n \else: \if:w x #1 n \else: \if:w n #1 n \else: \if:w N #1 N \else: \if:w S #1 N \else: \if:w s #1 n \else: \scan_stop: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: \fi: } %---------------------------------------------------------------------------------------------- \tex_message:D { Testing~the~commands~where~s-~and~S-type-arguments~are~grabbed~% by~calling~the~internal~functions~directly:^^J} \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {0}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {0}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {1}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {1}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {2}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {2}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {3}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {3}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {4}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {4}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {5}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {5}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Ns \tl_to_str:n {6}{\a}}~yields:~% \MYSTUFF_exp_times:Ns \tl_to_str:n {6}{\a}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {0}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {0}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {1}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {1}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {2}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {2}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {3}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {3}{\c} {\d}^^J } \tex_message:D { \tl_to_str:n{\MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {4}{\c} {\d}}^^Jyields:~% \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a} {\b} {4}{\c} {\d}^^J } \cs_new:Nn \MYSTUFF_BaseCommand:nNnN {\tl_to_str:n {{#1}#2{#3}#4}} \cs_generate_variant:Nn \MYSTUFF_BaseCommand:nNnN {sSsS} \tex_message:D {Meaning~of~\token_to_str:N\MYSTUFF_BaseCommand:sSsS\space is:^^J\cs_meaning:N\MYSTUFF_BaseCommand:sSsS^^J} \tex_message:D {Meaning~of~\token_to_str:N\exp_args:NsSsS\space is:^^J\cs_meaning:N\exp_args:NsSsS^^J} \tex_message:D {Meaning~of~\token_to_str:N\exp_not:s\space is:^^J\cs_meaning:N\exp_not:s^^J} \tex_message:D {Meaning~of~\token_to_str:N\exp_not:S\space is:^^J\cs_meaning:N\exp_not:S^^J} \cs_set:Npn \exp_args:NsSsS {\::N \::s \::S \::s \::S \::: {} } \tex_message:D {\MYSTUFF_BaseCommand:sSsS {0}{\a} {1}{\a} {2}{\a} {3}{\a}^^J} \tex_message:D {\exp_args:NsSsS \StringifyStopmarkerDelimited {0}{\a} {1}{\a} {2}{\a} {3}{\a} \stopmarker^^J} \cs_gset:Npn \MYSTUFF_BaseCommand:sSsS { \::s \::S \::s \::S \::: {\MYSTUFF_BaseCommand:nNnN} } \tex_message:D { \MYSTUFF_BaseCommand:sSsS {0}{\a} {1}{\a} {2}{\a} {3}{\a} } \stop Output into .log-file and onto console: Testing the commands where s- and S-type-arguments are grabbed by calling the i nternal functions directly: \MYSTUFF_exp_times:Ns \tl_to_str:n {0}{\a } yields: \a \MYSTUFF_exp_times:Ns \tl_to_str:n {1}{\a } yields: \b \MYSTUFF_exp_times:Ns \tl_to_str:n {2}{\a } yields: \c \MYSTUFF_exp_times:Ns \tl_to_str:n {3}{\a } yields: \d \MYSTUFF_exp_times:Ns \tl_to_str:n {4}{\a } yields: \e \MYSTUFF_exp_times:Ns \tl_to_str:n {5}{\a } yields: \f \MYSTUFF_exp_times:Ns \tl_to_str:n {6}{\a } yields: g \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{0}{\c }{\d } yields: {\a }{g}{\c }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{1}{\c }{\d } yields: {\a }{g}{\d }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{2}{\c }{\d } yields: {\a }{g}{\e }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{3}{\c }{\d } yields: {\a }{g}{\f }{\e } \MYSTUFF_exp_times:Nnfso \StringifyFourArguments {\a }{\b }{4}{\c }{\d } yields: {\a }{g}{g}{\e } Meaning of \MYSTUFF_BaseCommand:sSsS is: \long macro:->\exp_args:NsSsS \MYSTUFF_BaseCommand:nNnN Meaning of \exp_args:NsSsS is: \long macro:#1#2#3#4#5->\tex_expanded:D {\exp_not:N #1{\exp_not:s {#2}}{\exp_no t:S {#3}}{\exp_not:s {#4}}{\exp_not:S {#5}}} Meaning of \exp_not:s is: undefined Meaning of \exp_not:S is: undefined {\a }\b {\c }\d {\a }\b {\c }\d {\a }\b {\c }\d
- Error in \foreachby ozsu on March 26, 2025 at 10:54 pm
I am getting a weird error in a \foreach statement and it complains about the last element -- in this case it says No shape named v14 is known. If I comment out that line, it complains about the last entry in the list. Any suggestions as to what might be wrong? It is probably a subtle thing that I cannot see. Many thanks. Here is my MWE: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[every node/.style={circle, draw=black, thick, fill=gray!20, minimum size=8mm, inner sep=2pt}] % Nodes \node (v1) at (0,1.4) {$v_1$}; \node (v0) at (0.5,0.1) {$v_0$}; \node (v2) at (1.4,1.3) {$v_2$}; \node (v9) at (0.7,2.5) {$v_9$}; \node (v8) at (2.2,0.2) {$v_8$}; \node (v3) at (2.5,2.8) {$v_3$}; \node (v7) at (3.3,1.5) {$v_7$}; \node (v10) at (4.3,2.8) {$v_{10}$}; \node (v6) at (5,1.5) {$v_6$}; \node (v5) at (5,0.1) {$v_5$}; \node (v15) at (5.8,0.6) {$v_{15}$}; \node (v14) at (6.5,1.2) {$v_{14}$}; \node (v4) at (6.6,-0.4) {$v_4$}; \node (v11) at (7.5,0.6) {$v_{11}$}; \node (v12) at (7.1,2.0) {$v_{12}$}; \node (v13) at (6.2,2.8) {$v_{13}$}; % Edges \foreach \i/\j in { v0/v1, v0/v2, v1/v9, v2/v9, v2/v8, v3/v8, v3/v9, v3/v10, v7/v0, v7/v8, v7/v9, v7/v6, v10/v6, v6/v5, v5/v4, v4/v11, v6/v12, v6/v14, v6/v15, v12/v13, v12/v14, v13/v6, v11/v12, v15/v14 }% <- No extra newline or space here! { \draw[thick] (\i) -- (\j); } \end{tikzpicture} \end{document}
- Draw line through randomly generated points in Tikzby flawr on March 25, 2025 at 1:01 pm
Consider the following minimal example. We draw a number of circles with random y-coordinates using the \pgfmathrandominteger command. Is it now possible to somehow access these coordinates again? I did not manage to save them dynamically as nodes, and I'm not sure if it is even possible. In the end, I'm not interested in the circles themselves, but rather the resulting curve. \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=0.5] \pgfmathsetseed{1} \foreach \x in {0,...,10} { \pgfmathrandominteger{\y}{0}{2}; \draw (\x,\y) circle (0.1); } % draw a line connecting those? \end{tikzpicture} \end{document}
- Suppress indentation of first paragraph in multicols environmentby dedded on March 24, 2025 at 7:41 pm
I know I can use \noindent, but is there some cleaner-within-the-document way of suppressing the indentation of the first paragraph inside a multicols environment? Perhaps some kind of add-hook incantation? \documentclass{article} \usepackage{multicol} \begin{document} \section{One-column stuff} The quick brown fox\dots. % not indented (good) \section{Two-column stuff} \begin{multicols}{2} The quick brown fox\dots. % indented (bad) The quick brown fox\dots. % indented (good) \end{multicols} \end{document}