Week
- Why `\allowbreak` not workingby Eugene Zhang on February 4, 2025 at 10:15 pm
I have met with a problem with the justification of a paragraph using \allowbreak in LaTeX. The MWE LaTeX code is as below: \documentclass[11pt,twoside]{article}% \usepackage{amssymb} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{geometry} \newtheorem{theorem}{Theorem}[section] \begin{document} \begin{proof} Then $(\psi_n(x_1,\cdots,x_n))$ is a $n-$type of $\mathfrak{P}\,$ for $\,\mathfrak{P}\vDash\psi_n[\mathcal{P}^{1}(\varnothing),\cdots,\mathcal{P}^{n}(\varnothing)]$. Clearly $\{\allowbreak\eta_1(x_1),\cdots, \eta_n(x_1),\cdots,\psi_2(x_1,x_2),\cdots, \psi_n(x_1,x_2,\cdots,x_n)\cdots\}$ generates a maximum consistent set of formulas involving $\varnothing$ that is the only complete type of $\mathfrak{P}$. \end{proof} \end{document} The problem happens at\eta_n(x_1),... for it does not break there. I am totally lost because there is no \left bracket at all. Thanks.
- Put text on each mounted pdf's last pageby mf67 on February 4, 2025 at 8:55 pm
Is it possible to put a foot (end) note on each mounted pdf's last page? I could do it by \includepdf[pages=1-3]{file1.pdf} \includepdf[pages=4,pagecommand={//some text//}]{file1.pdf} \includepdf[pages=1-2]{file2.pdf} \includepdf[pages=3,pagecommand={//some other text//}]{file2.pdf} but it would require to know which page is the very last for each pdf.
- Unexpected roundoff with fpeval length comparisonby rallg on February 4, 2025 at 8:01 pm
This MWE shows it all. Same with pdflatex or lualatex: \documentclass{article} \newlength\mytemplength \setlength\mytemplength{8.5in} \newlength\myotherlength \setlength\myotherlength{8.5in} \edef\myresulta{\fpeval{\mytemplength<8.499in}} % expect 0, meaning false \edef\myresultb{\fpeval{\mytemplength<8.5in}} % expect 0, meaning false \edef\myresultc{\fpeval{\mytemplength<8.5001in}} % expect 1, meaning true \edef\myresultd{\fpeval{\mytemplength<\mytemplength}} % expect 0, meaning false \edef\myresulte{\fpeval{\mytemplength<\myotherlength}} % expect 0, meaning false \typeout{MYRESULTA=\myresulta} % provides 0, as expected \typeout{MYRESULTB=\myresultb} % provides 1, NOT expected \typeout{MYRESULTC=\myresultc} % provides 1, as expected \typeout{MYRESULTD=\myresultd} % provides 0, as expected \typeout{MYRESULTE=\myresulte} % provides 0, as expected \begin{document} foo \end{document} I realize that the length is not stored as inches. Nevertheless, I expect that when I retrieve the stored length, and compare it to 8.5in, the conversion of 8.5in should use the same algorithm as was used when a length is stored. But it seems that this is not the case. Thus, a roundoff error occurs. I can handle this by creating additional lengths, so that I compare stored values to stored values. I can handle this by comparing a stored length to a tweaked value. But I am mystified as to why the stored length is not equal to its unstored value.
- Why is \symsfup generating glyphs with serifs?by HerpDerpington on February 4, 2025 at 6:33 pm
Consider this example: \documentclass{article} \usepackage{unicode-math} \setmathfont{latinmodern-math.otf} \setmathfont[version=sans]{New Computer Modern Sans Math} \begin{document} \[ T|\symsfup{T}|\symup{T} \] \mathversion{sans} \[ T|\symsfup{T}|\symup{T} \] \end{document} which renders as Why does the \symsfup{T} have serifs? It is both in the sans version and also inside \symsfup (the same would occur with only \symsf).
- How can I use some semi-exotic characters in a source-code listing?by John on February 4, 2025 at 3:34 pm
Below is some text that I copy-pasted from the Isabelle theorem-prover interface. shows "P ≠ Q" and "P ≠ l" and "l ∩ m = m" and "∀P. P ≤ P" and "S ⟶ T" and "⟦U⟧ ⟹ V" and " ℝ ≠ ℕ" I'd like to typeset this with the listings package, thus: \documentclass[11pt,notitlepage,openany,oneside]{book} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \RequirePackage[svgnames]{xcolor} \usepackage{listings} %\usepackage{isabelle-listings} \begin{document} \begin{lstlisting}{language=Pascal} lemma times_assoc: fixes a::nat and b and c shows "P ≠ Q" and "P ≠ l" and "l ∩ m = m" and "∀P. P ≤ P" and "S ⟶ T" and "⟦U⟧ ⟹ V" and " ℝ ≠ ℕ" sorry end \end{lstlisting} \end{document} You can see that I'm telling the Listings package that it's Pascal rather than Isabelle, because telling it that I'm using Isabelle doesn't help, and the isabelle language-definition file is huge and (I believe) a red-herring for this question. Just as an FYI, the intended eventual output is something like this: and the isabelle listings language-description already does the coloring and bold-ing nicely when there are no special characters, so it's only the funny characters that are giving me trouble. My problem is that the result, upon running this with pdflatex I get the dreaded "LaTeX Error: Invalid UTF-8 byte sequence". When I switch to LuaLaTeX, things get a little better. I get the expected Package inputenc Warning: inputenc package ignored with utf8 based engines. and then a little later, the more significant Missing character: There is no ≠ (U+2260) in font ec-lmr10! Missing character: There is no ≠ (U+2260) in font ec-lmr10! Missing character: There is no ∩ (U+2229) in font ec-lmr10! Missing character: There is no ∀ (U+2200) in font ec-lmr10! Missing character: There is no ≤ (U+2264) in font ec-lmr10! Missing character: There is no ⟶ (U+27F6) in font ec-lmr10! Missing character: There is no ⟦ (U+27E6) in font ec-lmr10! Missing character: There is no ⟧ (U+27E7) in font ec-lmr10! Missing character: There is no ⟹ (U+27F9) in font ec-lmr10! Missing character: There is no ℝ (U+211D) in font ec-lmr10! Missing character: There is no ≠ (U+2260) in font ec-lmr10! Missing character: There is no ℕ (U+2115) in font ec-lmr10! ] (/compile/output.aux) I confess that at this point, I'm out of my depth in LaTeX. I don't know what ec-lmr10 is, or why it's being used, or what font I could be using to include these characters, and even if I knew what font that was, how to say "please use it during lstlistings. I've done my best to look for related questions (I read a lot about "LaTeX Error: Invalid UTF-8 byte sequence", for instance), but I'm in the position of not even knowing what words to search for. So: is there a way to typeset this kind of thing using listings?
- How to add arrows from one point on one plot to another point on second plot in tikz and pgfplotsby Mr.Price on February 4, 2025 at 2:57 pm
I have the following code to plot 3 lines from which 2 are just a translation of main plot 2 points up and down. I want to highlight that fact by adding arrows pointing up and down (of length 2 point) from middle plot to two other plots. How can I do that nicely in tikz and pgfplots without manually calculating the position of points on plot and adding/subtracting 2 from y coordinate? I would like to add these arrows every 20% of plot length (so 5 arrows in total). \documentclass[tikz, margin=3mm]{standalone} \usepackage{tikz} \usetikzlibrary{shapes, backgrounds, arrows.meta, fit,decorations.pathreplacing} \usepackage[dvipsnames]{xcolor} \usepackage{pgfplots} \usepgfplotslibrary{fillbetween} \pgfplotsset{compat=1.18} \usepackage{polski} \begin{document} \begin{tikzpicture}[ % show background grid, background grid/.style={thin, dotted, draw=gray,step=.5cm}, >=Stealth, remember picture, ] \begin{axis}[ xmin=-3.5, xmax=3.99, ymin=-4.5, ymax=4.99, xtick distance=1, ytick distance=1, xticklabels=\empty, yticklabels=\empty, extra y ticks={1}, % Dodatkowy tick na osi Y (dla b=1) extra y tick labels={$1$}, % Oznaczenie wartości b extra x ticks={1}, % Dodatkowy tick na osi Y (dla b=1) extra x tick labels={$1$}, % Oznaczenie axis lines=middle, % Osie przechodzą przez środek axis line style={-Stealth}, % Strzałki na osiach axis on top, % Osie na wierzchu xlabel={$X$}, % Oznaczenie osi X ylabel={$Y$}, % Oznaczenie osi Y xlabel style={at={(ticklabel* cs:1)}, anchor=north east}, % Pozycja etykiety X ylabel style={at={(ticklabel* cs:1)}, anchor=north west}, % Pozycja etykiety Y grid=both, % Dodaj siatkę grid style={dotted, gray!50}, % Styl siatki: kropkowana, szara set layers, % Włącz warstwy clip mode=individual, legend style={font=\tiny, scale=0.8, legend cell align=left}, legend pos=south west% Zmniejsza legendę ] \begin{pgfonlayer}{axis foreground} \addplot [domain=-3:3, samples=100, thick, color=Red] {x} node[pos=0.9, above] {\textbf{$\textcolor{Red}{f}$}}; \addplot [domain=-3:3, samples=100, thick, color=Orchid] {x+2} node[pos=0.9, above] {\textbf{$\textcolor{Orchid}{g}$}}; \addplot [domain=-3:3, samples=100, thick, color=Cerulean] {x-2} node[pos=0.9, above] {\textbf{$\textcolor{Cerulean}{h}$}}; \end{pgfonlayer} \end{axis} \end{tikzpicture} \end{document}
- Runaway Argument error due to restatable in newenvironment in Latexby Clément Michaud on February 4, 2025 at 11:04 am
I'm trying to wrap a restatable block in my own environment using \newenvironment to be able to customize my blocks and restate them but when I try to do that I get the following error: Runaway argument? ! File ended while scanning use of \thmt@collect@body. \par <*> ...mp/843342bb-1eed-41c5-9012-92b0e9271a56.tex Here is the simple code that raises this error: \documentclass{article} \usepackage{thmtools} \usepackage{thm-restate} \newenvironment{test}[2]{\begin{restatable}{#1}{#2}}{\end{restatable}} \begin{document} \begin{test}{thm}{test2} test \end{test} \end{document} This is compiled with pdfLatex and with version 2024. I also tried with NewEnviron from the environ package. With this, the command that is supposed to be used for restating the theorem gives an error: Undefined control sequence.. Can anyone help me figure out what's wrong? Is it an issue with restatable? Thank you in advance.
- Possible package clash -- XeLaTex + mla + graphicx?by crmdgn on February 4, 2025 at 2:23 am
I'm using MacTex 2024. This code \documentclass[12pt,letterpaper]{article} \usepackage{mla} \usepackage{graphicx} \begin{document} \begin{mla} Blah blah text text \begin{figure} \includegraphics[width=0.75\textwidth]{photo.jpg} \end{figure} \end{mla} \end{document} produces these errors: LaTeX Error: Cannot determine size of graphic in photo.jpg (no BoundingBox). [...5\textwidth]{photo.jpg}] LaTex Font Warning: Font shape `TU/ptm/m/n' undefined (Font) using `TU/lmr/m/n instead on input line 10 What is going on and how do I fix it?
- LuaLaTeX ignores kerning pairs among math glyphsby FKranhold on February 3, 2025 at 8:44 pm
(This issue might be somewhat related to this question.) Consider the following MWE: \documentclass{scrartcl} \usepackage{unicode-math} \setmathfont{MinionMath-Regular} \begin{document} $abcff,$ \end{document} When compiled with LuaLaTeX (you need the Minion Math font for this), the result looks as follows: Clearly, some kerning information is either missing or ignored here. However, it looks as if this is not an issue of the font: A quick inspection with FontForge shows that the font contains information for many kerning pairs, including “ff” and “f,” (the “italic f” being the unicode character U+1D453): I believe there must be a way to tell LuaLaTeX all these values. Even if LuaLaTeX cannot get these values from the OTF file itself (which would surprise me), I’d expect that one can tell LuaLaTeX all these kerning values manually, similar to this solution, but somehow adapted to the math font. (For completeness, I should mention that staircaise kerning for subscripts and superscripts works fine.) Update: I have just noticed that with TeX Gyre Pagella Math as math font, there is a quite noticable kerning effect at “cf” and “ff” – so apparently, the concept of kerning math glyphs is something LuaLaTeX is (in principle) perfectly capable of:
- Breakable option not working as desired in environment created by \newtcolorboxby Alan C. on February 3, 2025 at 5:28 pm
I've defined environments with the package tcolorbox that I want to break over pages. However they don't break as expected. When a box is broken over two pages, a full box is drawn around the portion of the box on each page. I think the box on the first page should not have a bottom border and should have square corners on the bottom and the box on the second page should not have a top border and should have square corners on the top. Does anyone know how to fix this? Here is a minimal working example with a picture of the compiled document. \documentclass[12pt,oneside]{article} \usepackage[letterpaper,margin=1.0in]{geometry} \usepackage{lipsum} \usepackage{tcolorbox} \tcbuselibrary{breakable} \newtcolorbox{boxedproof}[1]{breakable=true,colback=yellow!10,fonttitle=\bfseries,colframe=blue,colbacktitle=blue!10,coltitle=black,title={#1}} % End of Preamble \begin{document} \begin{boxedproof}{Solution} \lipsum[1-8] \end{boxedproof} \end{document}
- Autogenerating numbered pages with a prefixby David Jackson on February 3, 2025 at 1:02 pm
I need to generate pdf documents of a specific length (e.g., 456 pages) with nothing on them but page numbers and, ideally, a prefix. The reason that I need to do this is so that I can 'number' existing pdf documents by using pdftk to overlay the page numbers on to an existing pdf. Here is what I have so far: \documentclass[36pt,a4paper]{article} \usepackage{multido} \usepackage{xcolor} \usepackage[hmargin=.8cm,vmargin=1.5cm,nohead,nofoot]{geometry} \color{red} \LARGE \begin{document} \multido{}{456}{\vphantom{x}\newpage} \end{document} This creates the tex file. I then create the pdf, thus: pdflatex numbers.tex This gives me 'numbers.pdf' I can then apply the page numbers to an existing document (foo) in this way: pdftk foo.pdf multistamp numbers.pdf output foo_numbered.pdf I have two problems: I cannot seem to change the size of the page numbers or the opacity. I would like them to be very large but somewhat transparent in case the numbers overlay important information when merged with an existing pdf. I would like a create a prefix for the printed page numbers, so that instead of 1, 2, 3 etc I'd get foo-001, foo-002, foo-003 etc. I would be enormously grateful if anybody could help me.
- I'm having trouble drawing the hands. I just need simple hands pushing and pulling the box. Can anyone help me with this?by Ismael Joaquim on February 3, 2025 at 12:35 pm
Just like the figure below: The following is my MWE. \documentclass{standalone} \usepackage{tikz} \usepackage{xcolor} \usepackage{amsmath,esvect} \usepackage{amssymb} \begin{document} \begin{tikzpicture} % Block being pushed \draw[fill, color=orange!80, draw=red] (0,0) rectangle (1,1) node[below, yshift=-1.2cm, xshift=-1cm, color=red] {Push}; % Force applied to the block (Push) \draw[-latex, line width=1mm, color=blue] (1,0.5) -- (2,0.5) node[above] {$\vv{F}$(Force)}; % Hand pushing the block \draw[-, rounded corners] (-1,-0.1) -- (0,0) -- (0, 0.6) -- (-0.1,0.15) (0,0.5) -- (0,0.95) -- (-0.25,0.25) -- (-1, 0.30); % Block being pulled \draw[fill, color=orange!80, draw=red] (2,0) rectangle (3,-1) node[right, below, yshift=0.3cm, xshift=0.7cm, color=red] {Pull}; % Force applied to the block (Pull) \draw[-latex, color=blue, line width=1mm] (3,-0.25) -- (4,-0.25) node[above] {$\vv{F}$}; % Gray line below the pulled block \draw[-, color=gray, line width=0.5mm] (3,-0.5) -- (4.25,-0.5); \end{tikzpicture} \end{document}
- Setting node font size from withinby Cactus on February 3, 2025 at 12:18 pm
In the following example, I would like to set the font size of a node from "inside" the node's contents, i.e. without changing the node's font attribute: \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture} %% From https://tex.stackexchange.com/q/359189/2113 \def\gobblechar{\let\xchar= } \def\assignthencheck{\afterassignment\xloop\gobblechar} \def\xloop{% \ifx\relax\xchar \let\next=\relax \else \phantom{8}\makebox[0pt][r]{\xchar} \let\next=\assignthencheck \fi \next} \def\cellbits#1#2{\assignthencheck#1\relax \\ \assignthencheck#2\relax} \begin{scope}[scale=0.5,every node/.style={font=\large,align=center}] \draw[thin, densely dotted] (0,0) grid (7,1); \begin{scope}[shift={(0.5,0.5)}] \draw (0,0) node{1}; \draw (2,0) node{\cellbits{123}{456}}; \draw (4,0) node[font=\tiny]{\cellbits{123}{456}}; \draw (6,0) node{\tiny\cellbits{123}{456}}; \end{scope} \end{scope} \end{tikzpicture} \end{document} The nodes at (0,0) and (2,0) are just for reference. The node at (4,0) is exactly the output I would like to get. The node at (6,0) illustrates my problem. The \tiny size seems to be applied only to the first line (until the \\), and the line spacing and the second line all have size \large, i.e. the one based on the node's default font attribute: What can I put inside the (6,0) node's contents to get the same output as the (4,0) node? P.s.: If it can't be done "compositionally" i.e. if I have to change the definition of cellbits / xloop to "push in" the \tiny-ness, that is not optimal, but still fine.
- Letterspacing resets \Umathquadby FKranhold on February 3, 2025 at 10:45 am
The following MWE is to be compiled with LuaLaTeX: \documentclass{scrartcl} \usepackage{unicode-math} \usepackage{microtype} \begin{document} \Umathquad\textstyle=.3em $\langle a,b\rangle = 0$ \textls[60]{ABC} $\langle a,b\rangle = 0$ \end{document} It leads (with LuaHBTeX, Version 1.18.0 from TeX Live 2024/Arch Linux) to the following output (I know, the first line looks ugly, but that’s not the point): It looks as if, somehow, the usage of letterspacing “resets” \Umathquad. Is this intended behaviour? If so, is there any “global” analogue of \Umathquad that I can use instead, and which is independent of letterspacing?
- How to use `unknown .code` in `expl3` to achieve the effect of the key `color` in `tikz`?by myhsia on February 2, 2025 at 6:29 pm
Just like the title described, we know in tikz, the name of the key color could be omitted, that is \tikz \draw [color = red] (0,0) -- (1,0); equals to \tikz \draw [red] (0,0) -- (1,0); I'd like to achieve this effect via expl3, but I failed. One can get the error message Package xcolor: Undefined color ``'. by uncomment \skyrmion[red, text = {Hello, \LaTeX}] in the following MWE: \documentclass{article} \usepackage{xcolor} \ExplSyntaxOn \keys_define:nn { skyrmion / mwe } { color .tl_set:N = \l__skyrmion_color_tl, color .initial:n = black, text .tl_set:N = \l__skyrmion_text_tl, unknown .code:n = { \tl_set:Nn \l__skyrmion_color_tl {#1} } } \NewDocumentCommand \skyrmion { O{} } { \keys_set:nn { skyrmion / mwe } {#1} \textcolor {\l__skyrmion_color_tl} {\l__skyrmion_text_tl} } \ExplSyntaxOff \begin{document} \skyrmion[color = red, text = {Hello, \LaTeX}] % \skyrmion[red, text = {Hello, \LaTeX}] \end{document}
- How to write nested curly brackets with alligned cases?by MarcoM on February 2, 2025 at 3:18 pm
I'm trying to write this chart I have to make it as close as possible as it is a transcription of a manuscript, so the text must be aligned as in the picture. I can omit the underscores. I tried using cases in equation mode but the cases at the right side are not aligned vertically. This is the code: \documentclass{article} \usepackage{amsmath} \begin{document} \[ \text{Idee} \begin{cases} \text{variabili} & \text{(lettere)}\\ \text{costanti} \begin{cases} \text{generali} & \text{(idee deduttive)}\\ \text{particolari} \begin{cases} \text{non definite} & ({}_{"} \text{primitive})\\ \text{definite} & ({}_{"} \text{derivate})\\ \end{cases} \end{cases} \\ \end{cases} \] \end{document} I also tried using the shemata package but I couldn't even write the "cases" on the right. Any suggestions? Thanks
- \mu in ebgaramond-mathsby boink on February 2, 2025 at 8:10 am
My usual setup is \usepackage{ebgaramond} \usepackage[cmintegrals,cmbraces]{newtxmath} \usepackage{ebgaramond-maths} \usepackage[scr=boondox,cal=cm]{mathalfa} For some reason, \mu is not defined—or, rather, it shows up as a square box instead of as the character. (The same thing actually happens with \varOmega, but for obvious reasons this does not come up very frequently.) This occurs both on my computer and in Overleaf. I can redefine \mu by doing \DeclareSymbolFont{ntxletters}{OML}{ntxmi}{m}{it} \re@DeclareMathSymbol{\mu}{\mathord}{ntxletters}{"16} But this results in a character which doesn't really match with the way everything else looks. In this answer, which forms the basis for the ebgaramond-maths package in the first place, it seems like \mu is perfectly fine. I wasn't able to copy the procedure in that answer since I don't have the file EBGaramond12-Italic.otf in the ebgaramond directory. Does anybody know how to get \mu back?
- Removing core LaTeX syntax for brace-less commandsby Niklas on February 1, 2025 at 12:20 pm
I am using an Overleaf instance - pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) - LaTeX2e. I don't really know how to specify it. I don't want the behavior of LaTeX parsing commands with or without curly braces. I would like to specify one of those options and only one. A small example: For faster writing of mathematical symbols I got this new command: \newcommand{\Mvec}[1]{\boldsymbol{\mathit{#1}}} Works fine, but this actually creates two use cases for the command, either $\Mvec{v}$ or $\Mvec v$. I don't want the second one because it is bad practise and auto-correction always shows this one first. Thank you!
- Center figure even if size exceeds marginsby ncant on January 31, 2025 at 10:50 pm
I have this figure that is too large to be placed inside the body of my document. However, instead of resizing it, I would like to place it centered with respect to the area formed by the body, the margin note area, and the middle space combined, as indicated by the arrow. Also, I would like to extend the area for the caption text to the area I described. I'm using the \geometry package and I've tried using the \newgeometry and \restoregeometry commands, with no avail. Here's a minimal example of what I'm using right now: \documentclass{article} \usepackage[ a4paper, inner=2.5cm, outer=7.2cm, bottom=2cm, top=2cm, marginparsep=0.5cm, marginparwidth=5cm, showframe ]{geometry} \usepackage{svg} \usepackage{lipsum} \title{minimal} \author{Me} \begin{document} \begin{figure}[htbp] \includegraphics{NTS.pdf} \caption{\lipsum[1]} \end{figure} \end{document} Can you help me? Thanks.
- How can I remove spaces after multicols?by D G on January 31, 2025 at 4:18 pm
I want to remove the spaces after multicols. \documentclass[12pt]{article} \usepackage[a6paper,hmargin=5mm,vmargin=12mm]{geometry} \usepackage{fouriernc} \usepackage{multicol} \columnsep=5mm\relax \AtBeginEnvironment{multicols}{\vspace{-0.5cm}} % Space before multicols \AtEndEnvironment{multicols}{\vspace{-1.5cm}} % Space after multicols \usepackage{enumitem} \setlist[enumerate,1]{leftmargin=5mm,label=\arabic*.,nosep} \setlist[enumerate,2]{leftmargin=8mm,label=\alph*.,nosep} \newcounter{globalenumerate} \newenvironment{genumerate} {\begin{enumerate}\setcounter{enumi}{\value{globalenumerate}}} {\setcounter{globalenumerate}{\value{enumi}}\end{enumerate}} \begin{document} \begin{genumerate} % 1 \item Quick brown fox jumps over a crazy dog. \begin{multicols}{2} \begin{enumerate} \item It is not funny! \item Almost funny! \item Not sure! \item Hahaha! \end{enumerate} \end{multicols} % 2 \item Who invented $E=mc^2$? \begin{multicols}{2} \begin{enumerate} \item Mr.~Bean \item Mrs.~Bean \end{enumerate} \end{multicols} \end{genumerate} \end{document} My attempt with \AtEndEnvironment{multicols}{\vspace{-1.5cm}} does not work.
- How to obtain Unicode value of vertical variantby Mike Pugh on January 31, 2025 at 12:16 pm
This is a follow-up question to Is there a command like \left that does not require a \right?. I believe that I see a way to accomplish what I am trying to do, but it hinges on being able to obtain the Unicode value (or some other unique identifier) of a vertical glyph variant of a particular glyph. Let's say that I use the glyph that I have designed (which should ultimately resize both vertically and horizontally) as a delimiter in a \left-\right. pairing (which I now assume is the only way to persuade the font to return the correctly sized variant). Is there a way to determine the Unicode value of the returned variant? As of now, I have not assigned Unicode values to the variants; I used -1 instead and gave them names with extensions like .v1, .v2, etc. But I can change that (and assign them Unicode slots) if it proves to be necessary and put the variants in one of the PUAs. My presumption is that I need the Unicode value for a subsequent \Umathaccent command, but if there is another way to do this, I am all ears. Edit: Here is my two-step idea in greater detail. Since there is apparently no primitive in any of the TeXes which specifically handles bidirectional expansion, I tried to think about this in two steps. My font has m x n variants with names ending in .h1, .h2, ..., .hn (horizontal variants at base height), .v1, .v2, ..., .vm (vertical variants at base width), and .h1.v1, .h1.v2, ..., h1.vm, h2.v1, h2.v2, ..., .h2.vm, ..., hn.v1, hn.v2, ..., hn.vm. I put the first two types of variants (those at base height and base width, respectively) in the horizontal and vertical variant lists of the base glyph. Then, in each of the vertical variants (those ending with .v#) I put the horizontal variants .h1.v#, .h2.v#, ..., .hn.v# in the horizontal variants list. Doing it this way demands that we find the correct (base) vertical variant first (to act as the base glyph for the horizontal variants). Note that I could have reversed this by putting the vertical variants in the vertical variant lists of all of the horizontal variants. Finally, if I can use \left functionality (step one) to get the Unicode value of the correctly sized vertical variant (and, yes, I know that will mean assigning Unicode slots to all the variants, but that is okay--a minor modification to python code), then I can pass that to \Umathaccent (step two) to return the correct horizontal variant (with height already determined by the step one). I can find nothing in the OpenType specs that would prevent this, so I am hoping that if this is possible on the -TeX end, this can be done. I should also mention, regarding the horizontal/vertical reversal that I mentioned, that if I were to do that, it would then be necessary to get the correct horizontal size first and then the correct vertical subvariant. That did not seem as easy to me and I have not given it much thought. But maybe someone reading this will see that as the easier route and offer a suggestion. Edit 2: I recognize now that this has diverged drastically from the original posed question. I really had tried to keep this question simple, not intending to delve into these further areas unless it proved necessary. The Unicode value of the glyph is a necessary argument to \Umathaccent, which is why I need to obtain it for the glyph being used as the base for any horizontal variants. However, if that base glyph were itself a vertical variant, it would not--in general--have a Unicode value assigned to it. This is why I left the door open for other possibilities for those more knowledgeable of this material than I. But, if it is necessary to obtain a Unicode value as a unique identifier, then that can be arranged by assigning slots in the PUA (say, starting at F000--which is where I placed the base glyph anyway).
- Problem with Tree in TikZ [duplicate]by userr777 on January 31, 2025 at 10:50 am
I have the following code. However, the text "Droites gauches" is not visible. Any help ? Thanks in advance ! \documentclass[border=10pt]{standalone} \usepackage{verbatim} \usepackage{libertine} \usepackage{xcolor} \definecolor{ao(english)}{rgb}{0.0, 0.5, 0.0} \newcommand{\parallelsum}{\mathbin{\!/\mkern-5mu/\!}} \usepackage{tikz} \tikzset{ treenode/.style = {shape=rectangle, rounded corners, draw, align=center, top color=white, bottom color=blue!20}, root/.style = {treenode, font=\large, bottom color=red!30}, env/.style = {treenode}, dummy/.style = {treenode, bottom color=ao(english)!30}, kenny/.style = {treenode, bottom color=orange!30}, } \begin{document} \begin{tikzpicture} [ grow = right, sibling distance = 7em, level distance = 12em, edge from parent/.style = {draw, -latex}, every node/.style = {font=\footnotesize}, sloped ] \node[root] {\textcircled{1} $\vec{d}_1 \parallelsum \vec{d}_2$ ? } child { node[env] {\textcircled{2} Point d'inters. $I$?} child { node[dummy] {\textcircled{3} Droites secantes} edge from parent node [below] {\color{red}\bf oui} } child { node[dummy] {\textcircled{3} Droites gauches} edge from parent node [below] {\color{red}\bf non} } edge from parent node [below] {\color{red}\bf non} } child { node[env] {\textcircled{2} $A \in d_2$ ? } child { node[dummy] {\textcircled{3} Strict. parall\`eles} edge from parent node [below] {\color{red}\bf non} } child { node[dummy] {\textcircled{3} Droites confondues } edge from parent node [below] {\color{red}\bf oui} } edge from parent node [below] {\color{red}\bf oui} }; \end{tikzpicture} \end{document}
- Nesting commands with only one optional argumentby the_guruji on January 30, 2025 at 3:06 pm
Consider the two following ways to define commands \Foo and \Bar \newcommand{\Foo}[1][Foo]{\textbf{#1}} \newcommand{\Bar}[1][Bar]{\textit{#1}} \NewDocumentCommand{\Foo}{O{Foo}}{\textbf{#1}} \NewDocumentCommand{\Bar}{O{Bar}}{\textit{#1}} The first way raises an error when evaluating \Foo[\Bar[Baz]] about an extra \else, whereas the second one evaluates as expected. Placing the inner \Bar[Baz] inside curly quotes gives the right output for the first case. Why does this happen (is it something to do with the order of expansion being different in both cases) and what is the way to fix it? Is this a case where it is just not advisable to use \newcommand at all? MWE: % arara: pdflatex: {synctex: yes} \documentclass{article} \begin{document} \newcommand{\Foo}[1][Foo]{\textbf{#1}} \newcommand{\Bar}[1][Bar]{\textit{#1}} %\NewDocumentCommand{\Foo}{O{Foo}}{\textbf{#1}} %\NewDocumentCommand{\Bar}{O{Bar}}{\textit{#1}} \Foo[\Bar[Baz]] % Causes an error \Foo[{\Bar[Baz]}] % Compiles correctly \end{document}
- Why does my bibliography output depend on the citation keys?by schtandard on January 30, 2025 at 3:02 pm
I'm writing a document using the natbib (well, using revtex, which uses natbib). I noticed that my bibliography output sometimes depends on the citation keys used in the bibliography database, which I always presumed to be purely internal. Here's an MWE. % !TeX program = pdflatex % !TeX TXS-program:bibliography = txs:///bibtex % !BIB program = bibtex \begin{filecontents}[overwrite]{test.bib} @misc{first, note={This is a test.}, } @misc{second, note={This is another test.}, } @misc{fn:first, note={This is a test.}, } @misc{fn:second, note={This is another test.}, } \end{filecontents} \documentclass{article} \usepackage[numbers]{natbib} \bibliographystyle{unsrtnat} \begin{document} Hello World~\cite{first, second}. Bye World~\cite{fn:first, fn:second}. \bibliography{test} \end{document} As you can see, the second pair of entries receives an extra period compared to the first, even though the only difference between them is the fn: prefix to the keys. In the .bbl file, this appears as {\natexlab{b}}., so I assume it has something to do with a natbib feature. My guess would be that the mechanism for differentiating entries with identical author and year is triggered, though I don't understand why that would depend on the label. I was not able to find any information on the relevant feature (or the macro \natexlab) in the natbib documentation. Why is this happening? How can I configure this behavior? For context, though this should not affect the question above: In my field, footnotes are sometimes added in the form of bibliography entries, i.e. they appear in the main text just like any other reference, but in the References section there is just some text instead of bibliographic information. (Real footnotes are not used.) This is what I want to realize with these note-only @misc entries.
- How to use \pgfmathdeclarefunction in beamer?by flawr on January 30, 2025 at 7:34 am
I like using pgfmathdeclarefunction for writing functions that I reuse multiple times in the same tikzpicture. But now I realized that it does not seem to work well with \documentclass{beamer}, as soon as I put this tikz-plot in a \begin{frame} it complains. Without it there is no error. I would please like to understand why that doesn't work in beamer (it seems that it is not possible to use any arguments like #1) and whether there is any solution to solve this? Here is a minimal example: \documentclass{beamer} \usepackage{tikz} \begin{document} \begin{frame}{Plot of the Function} \begin{tikzpicture} % Define the function f(x) = x^2 \pgfmathdeclarefunction{f}{1}{% \pgfmathparse{#1^2}% } % Draw it \foreach \x in {0, 0.5, 1, 1.5, 2, 2.5} { \fill (\x, {f(\x)}) circle (2pt); % Plot points } \end{tikzpicture} \end{frame} \end{document} The error I get is Illegal parameter number in definition of \iterate. <to be read again> 1 l.28 \end{frame} You meant to type ## instead of #, right? Or maybe a } was forgotten somewhere earlier, and things are all screwed up? I'm going to assume that you meant ##.
- Defining \text_purify:n equivalents for commands with optional argumentsby User23456234 on January 30, 2025 at 2:19 am
l3text defines a command \text_purify:n that takes user input text as its argument, expands it, and then removes all formatting from the resulting text. It removes formatting from the text by removing non-expandable commands or by replacing a command with another command that is expandable---a purify equivalent defined with \text_declare_purify_equivalent:Nn. In the implementation in source3.pdf, many standard LaTeX2e formatting commands have purify equivalents declared with \text_declare_purify_equivalent:Nn such as \fontsize, \selectfont, the font size commands from \tiny to \Huge, \textrm, \textsf, \textbf, \textit, etc. When writing a new class or package that defines new formatting commands, it seems like it is best practice to define a purify equivalent using \text_declare_purify_equivalent:Nn for each of those formatting commands. (Note: \text_purify:n already correctly removes protected commands with no arguments.) Defining purify equivalents for commands with only mandatory arguments is easy: Simply define the purify equivalent as \use_none:n, \use_none:nn, \use_none:nnn, etc. I have written a package called fontscale (https://ctan.org/pkg/fontscale) that defines some formatting commands using \NewDocumentCommand. Some of these formatting commands have optional starred * arguments. It is also possible to define formatting commands with optional square bracket [] arguments. Currently, I use \NewExpandableDocumentCommand to define purify equivalents for formatting commands with optional arguments even though \NewExpandableDocumentCommand should be reserved for user-level commands. This is because, currently, there is no official interface in l3text or elsewhere for doing so. Thus, fontscale.sty defines purify equivalents as follows: (I use a w-type argument to define a purify equivalent for formatting commands defined with an s m argument specifier because this does not follow typical expl3 argument types.) \NewExpandableDocumentCommand \__fontscale_use_none_sm:w { s m } { } \tl_map_inline:nn { \fontscalesetup \SetFontStep \SetFontScale \SetFontSize \SetFontBaselineskip } { \text_declare_purify_equivalent:Nn #1 { \__fontscale_use_none_sm:w } } \text_declare_purify_equivalent:Nn \ScaleFont { \use_none:n } \text_declare_purify_equivalent:Nn \SetFontSizeBaselineskip { \use_none:nn } Questions: When defining new formatting commands for a class or package, is it always best practice to use \text_declare_purify_equivalent:Nn for each of those formatting commands? For formatting commands with optional arguments, is it OK to use \NewExpandableDocumentCommand to define expandable purify equivalents for use in \text_declare_purify_equivalent:Nn? Maybe this should also apply to formatting commands with only mandatory arguments because expl3 n-type arguments and ltcmd m-type arguments aren't quite the same as the latter natively disallows \par tokens.
- Looping over file to \draw circles from each lineby John on January 30, 2025 at 12:56 am
I want to loop over a file and draw a circle for each line in the file. The file has column x-coordinate, y-coordinate, radius like this: sources.dat 4,8,2 5,0,3 2,6,4 and I am trying to use the following script to do it: \documentclass[tikz]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[] \foreach \x/\y/\r in file {sources.dat}{ \draw (\x,\y) circle (\r); } \end{axis} \end{tikzpicture} \end{document} but I get the error Runaway argument? ile {sources.dat}{ \draw (\x ,\y ) circle (\r ); } \end {axis} \end \ETC. ! File ended while scanning use of \pgffor@next.
- Is there a reason why people use \begin and \end with tikz, when you can load it with way fewer letters with \tikz{}?by Jasper on January 29, 2025 at 10:01 pm
I want to make an inquiry into why people commonly use \begin{tikzpicture} and \end{tikzpicture}, instead of just \tikz{}. The reason for me asking is that I would prefer when making an MWE to use the smaller syntax, as it is less cumbersome to type. Most posts declare the environment using the \begin{tikzpicture} and \end{tikzpicture} syntax. This makes me question whether there is a reason for this. Are there any specific reasons that it is commonly done like this? Are there downsides to using \tikz{}? For example, take this classic bug report (posted first by @Zarko, and followed by many others): Why arc with angles given by "trig format=rad" gives wrong result? \documentclass[tikz]{standalone} \begin{document} \tikz{ \draw[trig format=rad, red] (1,0) arc[start angle=0, end angle=pi, radius=1]; \draw[domain=-1:1, samples=100, blue] plot (\x,{sqrt(1-(\x)^2)}); } \end{document} I simply don't like how much we have to write just to use tikz. I would prefer to use the smaller syntax which is less prone to typing errors. Can I safely do this?
- A problem with the justification of a paragraph in LaTeXby Eugene Zhang on January 29, 2025 at 4:38 pm
I have met with a problem with the justification of a paragraph in LaTeX. The MWE LaTeX code is as below: \documentclass[11pt,twoside]{article}% \usepackage{amssymb} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{geometry} \newtheorem{theorem}{Theorem}[section] \newtheorem{corollary}[theorem]{Corollary} \geometry{margin=1in,top=1.25in,bottom=1.25in} \begin{document} \begin{theorem} \label{43}\ Suppose for each $n<\omega,\,Q_{n}$ is a finitely generated set and $Q_{n}=\{\ast G_{n},Q_{n-1}\}$ with $Q_{0}\,=\,G_{0}\in V_{\omega}$ where $\{G_{n}\}$ form a finite cycle of length $l$ with $|G_{1}|<|G_{2}|<\cdots<|G_{l}|$ and $R_V(G_0)\geqslant\max\limits_{1\leqslant i\leqslant l}\{R_V(G_i)\}$\footnote{If $R_V(G_0)< R_V(G_j)$, let $G_0=\{*G_l,\cdots\{G_1,G_0\}\cdots\}$.}. Let $\mathcal{Q}_n=\langle\{Q_{n}\},\in,G_0,G_1,\cdots,G_l\rangle$, $\mathfrak{Q}_{n_p}=\left\langle\allowbreak\left\{ Q_{n_j}\colon j\leqslant p\wedge n_j\leqslant n_p\right\},\in,G_0,G_1\cdots,G_l \right\rangle$, $\mathfrak{Q}_q=\bigcup_{n_p<\omega}\mathfrak{Q}_{n_{p}(q)}= \left\langle\left\{Q_{{n_{p}(q)}}\colon p<\omega\right\},\in,G_0,G_1\cdots,G_l\right\rangle$, and $\mathfrak{Q}=\bigcup_{0\leqslant q< l}\mathfrak{Q}_{q}=\langle\{Q_{n}\colon n<\omega\},\in,G_0,G_1\cdots,G_l\rangle$. Then \end{theorem} \end{document} The problem happens inside $\mathfrak{Q}_{n_p}=\left\langle\allowbreak\left\.... I have tried to break the bracket to make alignment work by adding allowbreak or \\ but both fail. I wonder how to break the bracket to make alignment work. Thanks.
- Write chemical formulas on an arrowby Nicolas on January 29, 2025 at 1:41 pm
In a previous intervention (Write as a subscript above a reaction arrow), I saw how I could subscript text placed on an arrow in a reaction environment This method is not very suitable when writing chemical formulas because it requires adding the $\sb{XX}$ commands several times to obtain, for example: with this code : \documentclass{article} \usepackage[modules={all}]{chemmacros} \begin{document} \begin{reaction} C=C + H-X ->[H$\sb{2}$SO$\sb{4}$] CH-CX \end{reaction} \end{document} Isn't there an easier way to write reaction balances ? I do not want to use the chemfig package for this review because I want to be able to list the reactions