• How do I use a command with optional arguments in a caption without causing an error in lists of figures/tables?
    by Jonathan on April 18, 2025 at 4:54 pm

    I would like to be able to use commands with default arguments in captions of figures/tables without causing an error in \listoftables or \listoffigures. For example, the following code causes an error stating "Undefined control sequence.": \documentclass{article} \begin{document} \listoftables \newcommand{\acommand}[1][X]{b(#1)} \begin{table} \caption{I'm using a command $\acommand$ in a caption.} \end{table} I'm using the command again $\acommand[Y]$. \end{document} This code does not generate any errors if the optional argument is removed from the definition of \acommand (and any calls). Things like \protect and supplying the argument doesn't make any difference. Anyone know how to avoid this error? Edit: Sorry I forgot to mention that the definition of \acommand is deliberately placed after the call to \listoftables. In reality I'm managing a very large document made of many subdocuments and to keep things organised, its extremely helpful to have my commands defined in the relevant subdocuments/subsections instead of defining everything before the \listoftables which must appear near the start of the document. This works for any commands that don't have optional arguments. You can test this by removing the optional argument in the MWE above and see that the error disappears. I'm hoping there is a way that I can remove the error while retaining optional arguments.

  • Why does chemfig not give desired result?
    by youthdoo on April 18, 2025 at 11:10 am

    I was using chemfig to draw organic chemistry. I wanted to add a aldehyde group to a branch on a benzene ring. My code is \documentclass{standalone} \usepackage{chemfig} \begin{document} \chemfig{*6(=-=(-O-CH_2C(=[:90]O)-H)-=-)} \end{document} But it gives I want to have the carbonyl bond (C=O) move to the right carbon atom to correctly form the aldehyde group. What is going wrong here and what should I do?

  • label equations with subindex
    by underflow on April 18, 2025 at 8:06 am

    I have a system of equations that I would like to label with subindex. Example: \documentclass{amsart} \begin{document} \begin{equation} X + Y = Z. \label{sum} \end{equation} A group of equations: \begin{align} A &= B \label{one} \\ C &= D \label{two} \end{align} \end{document} In it's current form the two equations in between {align} are labeled as (2) and (3); instead I want them to be labeled as (2.1) and (2.2). What is the "correct" way to automate/implement this? THANKS!

  • PGFPlots: Coordinate Arithmetric, curious behavior when zero vector is not added
    by Grass on April 18, 2025 at 7:00 am

    The other day, I was absolutely puzzled by why my code didn't work. Turns out, adding the zero vector +(0,0) magically fixed everything. I'm curious to find out why, though unfortunately I have had no luck finding answers on the web so far. Could someone here explain this? \documentclass[tikz]{standalone} \usetikzlibrary{calc} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \begin{document} % Nice, expected behavior \begin{tikzpicture} \begin{axis}[ xmin=-5, xmax=5, ymin=-5, ymax=5, ] \draw[thick,blue] (0,0) -- ($(0,0)+2*(axis direction cs:-1,1)$); \end{axis} \end{tikzpicture} % Inexplicable yeeting `to infinity' \begin{tikzpicture} \begin{axis}[ xmin=-5, xmax=5, ymin=-5, ymax=5, ] \draw[thick,blue] (0,0) -- ($2*(axis direction cs:-1,1)$); \end{axis} \end{tikzpicture} \end{document} The first tikzpicture produces while the second one produces

  • No counter subfigure defined in memoir
    by Nukesub on April 18, 2025 at 3:03 am

    I am trying to get the following code to compile based on an example given in the memoir manual regarding sub figures (pg. 180). When I try to compile this I get the following error: No counter 'subfigure' defined.. I am using LuaLaTeX 1.17.0 (TeX Live 2023). Does anyone know how I can fix it? % main.tex \documentclass[11pt,letterpaper,oneside]{memoir} \begin{document} \begin{figure} \centering \subbottom[Subfigure 1\label{sf:1}]{\fbox{SUBFIGURE ONE}} \hfill \subbottom[Subfigure 2\label{sf:2}]{\fbox{SUBFIGURE TWO}} \caption{Figure with two subfigures} \label{fig:twosubfig} \end{figure} \end{document} Edit: Spelling

  • End of proof symbol [duplicate]
    by kubo on April 17, 2025 at 12:14 pm

    I am using a new template, and the end of proof symbol is not being shown at the end of my proofs. I have been adding it manually with \hfill \qed but I'd like to know if there is a way to fix the problem from the root. Here are the packages my template uses: \documentclass[runningheads]{llncs} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{boxedminipage} \usepackage[noend]{algpseudocode} \usepackage{comment} \usepackage{pgfplots} \pgfplotsset{compat = newest} \usepackage{amsmath} \usepackage{amssymb} \usepackage{multirow} \usepackage{threeparttable} \usepackage[colorinlistoftodos]{todonotes} I know simmilar questions have been asked before but I checked them and didn't find an answer to my question. Could someone help me?

  • How to rewrite a syntactic tree from XYLING to FOREST
    by Espen on April 17, 2025 at 11:51 am

    I'm writing a linguistic paper and was told by the publisher than they "cannot process" trees written with the xyling package, so they asked me to do it with FOREST instead. I'm new to FOREST, but I downloaded the manual, loaded the package and started redoing my trees. As expected, issues arise. In one of my trees, I used a feature in xyling that allowed me to insert into my tree an arrow with text under it, and also a dotted (or full), diagonally running line with text surrounding it. I have absolutely no idee how to reproduce this with the FOREST package, and having scrolled through all the trees given in the manual, I see no example of anything similar... Tips? Below a MWE with the relevant bits of code (based on xyling syntax) between the marks % >> and % <<: \documentclass[output=paper,colorlinks,citecolor=brown % ,hidelinks % showindex ]{article} \usepackage[backend=biber, style=authoryear-comp, sortcites=false, maxcitenames=2, mincitenames=1, maxbibnames=5, uniquelist=false, uniquename=false, useprefix=false, safeinputenc]{biblatex} \usepackage{langsci-optional} \usepackage{langsci-gb4e} \newcommand{\orcid}[1]{} \RequirePackage[color,all,dvips,dvipdfm]{xy}% sigh force dvipdfm without getting a option clash error, in order to make the branches of \Tree show on the pdf with xyling \usepackage{xyling} \usepackage{forest} \begin{document} \begin{exe} \ex\label{FinP} \Treek{1} { & \K{ForceP}\B{dl}\B{dr} && % >> \K{$\scriptstyle transfer $}\GBkk{2,1}{2,1}{ddlll}{-} \\ % << \K{Force$^0$}\OO && \K{TopP}\B{dl}\B{dr} \\ & \K{Den Wagen} && \K{FocP}\B{dl}\B{dr} \\ && \K{Meinem VATER} && \K{FinP}\B{dl}\B{dr} && % >> \K{$\scriptstyle transfer$}\Below{$\scriptstyle deactivated$}\GBkk{2,1}{2,1}{ddlll}{.} \\ \K{$\scriptstyle `The$}\Below{$\scriptstyle `bottleneck' $}\GBkk{2,6}{2,6}{rr}{->} % << &&& \K{Fin$^0$}\OO \Below{\textbf{habe} [\sout{$\phi$}]} && \K{TP}\TRi[0] \\ &&&&& \K{ich \sout{\textbf{habe}} \sout{meinem VATER}}\Below{\sout{den Wagen} verkauft} } \end{exe} \end{document}

  • tikz-qtree tree moves to next page even with sufficient space
    by cs_to_cs on April 17, 2025 at 11:13 am

    I am creating a handout that includes some trees created using tikz-qtree, and I'm having two inter-related issues: one of unnecessary white space and one where a potential solution behaves unexpectedly. Sometimes, a tree ends up moved to the next page even though there's enough space for it to fit, leaving a lot of white space unnecessarily. I can force the tree to fill that space with something like \vspace{-6em}, but I don't understand why it works like it does. First, if you only do -1em for example, up to 5, nothing changes, and then with -6em, the tree does move to the previous page to fill the white space BUT too high, overlapping the text, like this (notice the "1" at the bottom where the page ends): I understand that as you move something up it will eventually overlap text above where it would have been. What I don't understand is why 1 more em is just enough to move the tree even though the space under the tree, once it moves, is clearly much more then 1em. In summary, (A) why does the tree move to the next page when there is enough space for it and (B) why does \vspace not work until some tipping point, overlapping the text? MWE (BUT recall that you need to adjust \vspace{-2em}to see what happens with the tree) \documentclass{article} \usepackage{tikz} \usepackage{tikz-qtree} \usepackage{tikz-qtree-compat} \usepackage{amsmath} \usepackage{amssymb} \begin{document} \section{Some heading} \begin{itemize} \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \item Some text to fill this page. \end{itemize} \section{Another heading} \begin{itemize} \item Some text. \vspace{-2em} \end{itemize} \begin{tikzpicture}[baseline]\tikzset{every tree node/.style={align=center,anchor=north}} \Tree [.CP \phantom{Test} [.C' \node(C){C\\$\varnothing$}; [.TP [.\node(SpecTP){DP}; ] [.T' \node(T){T}; [.VoiceP \phantom{Test} [.Voice' \node(Voice){Voice\\t_{\text{pass}}}; [.VP [.V' \node(V){V}; \node(Object){t_{\text{DP}}}; ] ] ] ] ] ] ] ] \draw[->] (Voice) to[out=240,in=240,looseness=1.9] (T); \draw[->] (Object) to[out=240,in=200,looseness=1.2] (SpecTP); \end{tikzpicture} \end{document}

  • Tipauni problem with accent marker on LaTex
    by 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}

  • Beamer slides, presenter's screen shows the slides with \setbeamercovered{transparent}
    by Łukasz Grabowski on April 17, 2025 at 10:00 am

    My problem is as follows. I prepare my slides with a lot of pauses (sometimes after every word), to try to imitate "writing on a blackboard". I know it's not everyone's cup of tea, but let's not get into it. Now what I would ideally like to achieve is that the projector should show the slides, and my monitor screen should show the same slides but with \setbeamercovered{transparent}, so that I actually know what's coming and where exactly I am in the slide. Is there a way to achieve it, for example with some variation of \setbeameroption{show notes on second screen=right}? But any solution would be welcome. Edit: Per the request in the comments, I would like to have the following file shown on the projector: \documentclass{beamer} \begin{document} \begin{frame} This \pause is \pause a\pause sample \pause presentation. \end{frame} \end{document} and the following file on the computer screen: \documentclass{beamer} \setbeamercovered{transparent} \begin{document} \begin{frame} This \pause is \pause a\pause sample \pause presentation. \end{frame} \end{document} in such a way that when I press a button then both the projector and the computer screen go to the next slide.

  • Tagged PDF & float here [H]
    by LeO on April 17, 2025 at 7:46 am

    With the new tagging possibilities a "figure" should reside within a figure tag. To my understanding all the figure environments are float environments. Nevertheless I need to display a figure in the same text flow as it "set" - so basically I need to place the figure Here. There have been several threads with the discussion how to solve the this topic - without tagging enabled. One of the most common is to use the package float with the option H. A very simplistic MWE (for demonstration purpose only) \DocumentMetadata{ pdfstandard = ua-2, pdfversion = 2.0, testphase = latest, lang=de, } \documentclass{article} \usepackage[showframe]{geometry} \usepackage{float} \usepackage{xcolor, kantlipsum} \begin{document} \kant[4-6] \begin{figure}[H] \framebox[\textwidth]{ \begin{minipage}{0.9\textwidth} \kant[64] \end{minipage} } \caption{quick caption} \end{figure} \underline{\color{red} Some text inbetween} \kant[64-67] \end{document} The red underlined text should appear below the figure. As mentioned on the compatibility site float is incompatible with the option [H]. When I compile the above code I get Package tagpdf Warning: Parent-Child 'Document/pdf2' --> 'Caption/pdf2'. (tagpdf) Relation is not allowed (struct 2, /Document --> (tagpdf) struct 15) on line 21 because the caption is not properly tagged. I've read different solutions but remain unclear if they work generally. At least for this scenario [h!] won't help. How to force a figure to be placed "Here" and have a valid tagged PDF?

  • Reproduce the image using TikZ
    by Alberto Belmonte on April 16, 2025 at 7:40 pm

    I'm working on some school notes, but my skills aren't enough to create something similar to the image. It's something much more clumsy. I'm sure that with TikZ something very similar can be done. Image: My code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{tikzmark, shapes.geometric, shapes.arrows, fit, calc, positioning} \begin{document} \begin{tikzpicture} % Ecuación base \node[draw=none, font=\large] (equation) at (0,0) {$\sqrt[n]{a} = b$}; % Etiqueta de Índice (n) \node[draw=red, thick, rectangle, rounded corners, inner sep=5pt, align=center, color=red] (index) at (-2, 1.5) {Índice}; \draw[thick, red, ->] (index.east) -- (equation.north west); % Etiqueta de Radicando \node[draw=blue, thick, rectangle, rounded corners, inner sep=5pt, align=center, color=blue] (radicando) at (-2, 0) {Radicando}; \draw[thick, blue, ->] (radicando.east) -- (equation.west); % Etiqueta de Raíz \node[draw=green, thick, rectangle, rounded corners, inner sep=5pt, align=center, color=green] (raiz) at (2, 0) {Raíz}; \draw[thick, green, ->] (raiz.west) -- (equation.east); \end{tikzpicture} \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}

  • Change page margin for first page within environment
    by Dave on April 16, 2025 at 5:27 pm

    I have created a custom environment wherein the first page on which the environment starts should have a modified top margin, for example to insert a picture (see gray rectangle). All following pages should go back to the original set geometry. Setting the new geometry is no hassle, but restoring the original geometry simply does not work. I appreciate all help! My goal: Status quo: My code: \documentclass[a4paper,11pt]{book} \usepackage[ a4paper, portrait, heightrounded, showframe, inner = 20.0mm, outer = 20.0mm, top = 30.0mm, bottom = 40.0mm, nohead, nomarginpar, footskip = 20.0pt, footnotesep = 7.0pt, ]{geometry} \pagestyle{empty} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{expl3} \ExplSyntaxOn \NewDocumentEnvironment{custom}{}{ \clearpage \newgeometry{ heightrounded, inner = 20.0mm, outer = 20.0mm, top = 99.0mm, bottom = 40.0mm, } \begin{tikzpicture}[remember ~ picture, ~ overlay] \filldraw[fill = gray] (current ~ page.north ~ west) rectangle ++(\paperwidth, -99mm); \end{tikzpicture} }{} \ExplSyntaxOff \usepackage{lipsum} \begin{document} \begin{custom} \lipsum \end{custom} % \begin{custom} % \lipsum % \end{custom} \end{document}

  • Adobe Acrobat not displaying inline image
    by 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 \MakeUppercase
    by 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 function
    by 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.

  • Tagged PDF & Metadata
    by LeO on April 15, 2025 at 8:44 am

    I want to set metadata for Tagged PDFs but somehow this fails. I tried to narrow down the source of this issue and excluded all packages. Therefore I follow the example from Ulrike \DocumentMetadata{ lang=en, % testphase=latest, % pdfstandard=UA-2, } \documentclass{article} \ExplSyntaxOn \pdfmanagement_add:nnn{Info}{Title}{(My~other~Story)} \pdfmanagement_add:nnn{Info}{Author}{(Someone)} \ExplSyntaxOff \begin{document} aaa1 \end{document} It seems like as soon as the ua-2 is enabled the metatags are gone. pdfinfo clearly writes Custom Metadata: no Following Wiki I couldn't see a reason why MetaTags are not allowed. Is there a way to set the attributes? NOTE: Since its a MWE I focused on two attributes only. For real life I need additional attributes. Running on lualatex 1.22.0

  • Automatize paragraph break
    by Vincent Krebs on April 14, 2025 at 10:32 pm

    When I quote an attested example, I mention the source at the end of the last line, right-aligned. So here as an example, I use my \web[year] command, which displays (WEB, *year*). But sometimes the last line is too long and -- when it doesn't produce an overfull hbox -- the source is displayed on the next line. However, this is not desirable as the last line of text is then stretched because I want examples justified and here the paragraph is not ended. In such cases, I resort to the starred command, which forces a new paragraph where needed. Now I'd like to automatize the process, i.e. automatically force paragraph break whenever required. Any idea? MWE \documentclass{article} \usepackage{ragged2e} \NewDocumentCommand{\web}{so}{% \IfBooleanTF{#1}{\par}{\unskip}\begingroup\normalsize\hspace{0.5em}\raggedright\hspace*{\fill}% (\textsc{web}\IfValueT{#2}{,~#2})\endgroup\par} \parindent0em \begin{document} Cette phrase est suffisamment courte pour que la source tienne.\web[2025] \vspace*{3ex} Cette phrase prend deux lignes, mais la deuxième ligne est suffisamment courte pour que la source puisse y être mentionnée.\web[2025] \vspace*{3ex} Ceci tient sur une ligne, mais il n'y a pas assez de place pour la source.\web[2025] %Overfull hbox ! \vspace*{3ex} Ceci tient sur une ligne, mais il n'y a pas assez de place pour la source.\web*[2025] %La variante étoilée résout le problème. \vspace*{3ex} Cette phrase prend deux lignes, et la deuxième ligne est trop longue trop longue trop longue trop longue trop longue pour que la source y soit mentionnée.\web[2025] %Ici la deuxième ligne est étirée car elle est à l'intérieur du paragrphe, cela ne va pas. \vspace*{3ex} Cette phrase prend deux lignes, et la deuxième ligne est trop longue trop longue trop longue trop longue trop longue pour que la source y soit mentionnée.\web*[2025] %La variante étoilée résout le problème. \end{document} Edit with a more complex example and David's code MWE \documentclass{article} \usepackage{fontspec} \setmainfont{Times New Roman} \NewDocumentCommand{\web}{o}{% \ifhmode\unskip\fi \begingroup \normalsize \nolinebreak \hspace{0pt plus 1fill}\mbox{}% \linebreak[0]% \hspace*{.5em plus 1fill}% (\textsc{web}\IfValueT{#1}{,~#1})% \endgroup \par} \parindent0em \begin{document} Both poly-d-lysine and matrigel coating of plastic culture vessels seemed to alter the assemblages of cells, allowing for \textbf{\textit{more more frequent} culture} of fibroblasts, spindle-shaped cells and larger cells.\web \end{document} It is solved by replacing \linebreak[0] with \nolinebreak[2] MWE \documentclass{article} \usepackage{linguex} \usepackage{fontspec} \setmainfont{Times New Roman} \NewDocumentCommand{\web}{o}{% \ifhmode\unskip\fi \begingroup \normalsize \nolinebreak \hspace{0pt plus 1fill}\mbox{}% \nolinebreak[2]% \hspace*{.5em plus 1fill}% (\textsc{web}\IfValueT{#1}{,~#1})% \endgroup \par} \parindent0em \begin{document} Both poly-d-lysine and matrigel coating of plastic culture vessels seemed to alter the assemblages of cells, allowing for \textbf{\textit{more more frequent} culture} of fibroblasts, spindle-shaped cells and larger cells.\web \end{document}

  • How do I tag a margin note?
    by Teepeemm on April 14, 2025 at 1:40 pm

    I would like to create an accessible pdf that uses \marginnote. I am aware that the package marginnote is currently incompatible with the tagging project, but I assume that means the package is not able to tag all margin notes reliably. Since I have complete control over my file, would I be able to insert the appropriate commands to get a properly tagged pdf? To borrow (and adjust) a specific example from https://github.com/latex3/tagging-project/issues/165, the following code \DocumentMetadata{testphase={latest},lang=en-US} \documentclass{article} \usepackage{marginnote} \begin{document} Some text\marginnote{a margin note} \end{document} has two errors about the number of begin (3) and end (2) hooks differing, as well as four warnings about that a Parent-Child "Relation is not allowed". What would need to happen to make this file produce a properly tagged pdf? Edit Ulrike Fischer has shown how to do this for the marginalia package (+1). Looking through that answer, it appears to wrap \UseTaggingSocket around \setbox and after \@parboxrestore. Doing the same to marginnote (and dropping the tests for older TeXLives), I think the following should work: \DocumentMetadata{testphase={latest},lang=en-US,uncompress} \documentclass{article} \usepackage{marginnote} % default options: verbose, fulladjust, parboxrestore \makeatletter \renewcommand{\mn@zbox}[1]{% \bgroup \UseTaggingSocket{marginpar/begin}% \setbox\@tempboxa\vbox{#1}% \UseTaggingSocket{marginpar/end}% \ht\@tempboxa\ht\strutbox \dp\@tempboxa\dp\strutbox \wd\@tempboxa\z@ \box\@tempboxa \egroup }% \renewcommand*{\mn@parboxrestore}{% \@tempskipa\parskip \@parboxrestore \UseTaggingSocket{para/restore}% \parskip\@tempskipa }% \renewcommand{\mn@vlap}[1]{% \UseTaggingSocket{marginpar/begin}% \setbox\@tempboxa\vbox to \ht\strutbox{#1\vss}% \UseTaggingSocket{marginpar/end}% \box\@tempboxa\vskip-\baselineskip } \makeatother \begin{document} before \marginnote{note} after \end{document} The \mn@zbox renewcommand has fixed two of the warnings, but the other two warnings and the two errors remain. Am I missing an easy fix with marginnote, or does this suggest that marginnote may be hopelessly more complicated, so that I should switch to marginalia?

  • How can one nest \csname-\endcsname constructs so as to apply macros dynamically?
    by HOO on April 14, 2025 at 10:22 am

    I am trying to nest \csname-\encsname constructs so as apply macros dynamically. However, I am unsuccessful. Given below is my MWE, which does not work as expected. I expect the printout to be "Ostrich is a bird." However, I do get "birdOstrich". I would be very grateful if someone could help me figure out how to nest the \csname-\encsname constructs correctly so as to get the desired result. \documentclass[english,10pt,a4paper]{article} \usepackage[T1]{fontenc} \usepackage{babel} % \def\Isbird{bird} \def\Ismammal{mammal} \def\birdInterp#1{#1 is a bird.} \def\mammalInterp#1{#1 is a mammal.} % % \begin{document} \csname Isbird\endcsname\csname Interp\endcsname{Ostrich} \end{document}

  • PDF-Tagging and additional sub section levels
    by 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 Lua
    by 青山漫步 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.

  • Alternative solution to a symbol I need to use in a document
    by Math Attack on April 13, 2025 at 2:40 pm

    Context I need to use a symbol inside a document. The symbol in question is V-shaped with a vertical bar in the middle (more or less $\backslash |/$, but all together). My work I brutally resorted to using tikz to create this symbol I defined \newcommand{\rs}{\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \draw [line width=0.7pt] (0.,0.)-- (0.,0.2)(-0.08660254037844388,0.15)-- (0.,0.)(0.,0.)-- (0.08660254037844388,0.15); \end{tikzpicture}} and the result is considering that I would have to use this symbol several times within the document, I would not want it to become too heavy or generally slow to fill out since it is in practice full of images at the end Question Are there any lighter alternatives to this solution? I also searched in different types of different alphabets but I did not find similar letters. I searched mostly in the Cyrillic alphabet but the most similar symbol is this one ꙟ, but curved on one side (it's also upside down, but that's easily fixed).

  • How to apply the libertine font to a specific range in pdfLaTeX?
    by myhsia on April 12, 2025 at 5:39 pm

    This question is an extension of the: question. I should use the Linux Libertine O font to typeset the W of the WikipediA logo. But, I don't want to apply the libertine font globally, only apply it to the logo. For xelatex, this is quite simple: \documentclass{article} \usepackage{fontspec} \begin{document} This is the WikipediA Logo: \textsc{\fontspec[StylisticSet = 5, Extension = .otf]{LinLibertine_R}WikipediA}. The font in the logo should in the LinLibertine font. This document is compiled by \verb|xelatex|. \end{document} But, how can I achieve this in pdflatex? In pdflatex, I could only load the libertine package, and the font is globally changed. I only want to change the WikipediA logo's font: \documentclass{article} \usepackage[mono=false]{libertine} \begin{document} This is the WikipediA Logo: \textsc{\libertineGlyph{W.alt}ikipediA}. The font in the logo should in the LinLibertine font. This document is compiled by \verb|pdflatex|. \end{document} I think that in pdflatex, the libertine could globally set the font, so there might be an interface to set the font in a group.

  • Wrong stanza numbering in reledmac/reledpar when using \startlock and \endlock
    by flogrz on April 12, 2025 at 2:20 pm

    This is a follow-up question to: Stop numbering for paragraph in reledmac / reledpar When a stanza is followed by a paragraph, that shall not be numbered (by adding \startlock and \endlock), and the last verse is longer than one line, both those lines are numbered when only the first should be. I couldn't find out how to fix this. MWE: \documentclass[12pt,a4paper]{scrbook} \usepackage[]{reledmac} \usepackage[]{reledpar} % Set stanza indents \setstanzaindents{8,5} \setcounter{stanzaindentsrepetition}{1} % Print a line number for every second line on the left side \firstlinenum{1} \linenumincrement{1} % Disable the line numbering on the right side \firstlinenumR{1000000000} \begin{document} \begin{pairs} \begin{Leftside} \beginnumbering \begin{astanza} verse verse verse 1!& verse verse verse 2!& verse verse verse 3!& verse verse verse verse 4!\& \end{astanza} \pstart\startlock Some other text which should not be in verse form and therefore not numbered (basically an annotation which still will be translated). Let's just make it longer so we can see how it looks when spread over multiple lines.\endlock \pend \begin{astanza} verse verse verse 1!& verse verse verse 2!& verse verse verse 3!& verse verse verse 4!\& \end{astanza} \endnumbering \end{Leftside} \begin{Rightside} \beginnumbering \pstart This is a translation paragraph. Still just a translation paragraph. There is nothing interesting in here, please move on. \pend \pstart This is a translation paragraph. Still just a translation paragraph. There is nothing interesting in here, please move on. \pend \begin{astanza} verse verse verse 1!& verse verse verse 2!& verse verse verse 3!& verse verse verse 4!\& \end{astanza} \endnumbering \end{Rightside} \end{pairs} \Columns \end{document} Thanks for your help!

  • Coloring areas between curves in TikZ
    by sergiokapone on April 12, 2025 at 8:39 am

    I need to fill the areas shown in the figure (MWE). I would like to use \fill between the characteristic points, but unfortunately it is quite difficult and not practical to recreate the shape of the segment between the lobs (0, 2) and (C). I need an acceptable way to do this. \documentclass[tikz, border=0.5cm]{standalone} \usetikzlibrary{intersections} \begin{document} \begin{tikzpicture} \draw[thick] (0,0) rectangle (5,6); \draw[name path=A, blue] (0, 2) to[out=0, in=265] (2,6); \path[name path=B, red] (2, 0) -- (1,6); \draw [name intersections={of=A and B, by=C}] (2, 0) -- (C); \node[font=\scriptsize, text width=1.5cm] at (1,1) {Area to fill by red color}; % This node is %only to indicate the area to be painted \node[font=\scriptsize, text width=1.5cm] at (3,3) {Area to fill by blue color}; % This node is %only to indicate the area to be painted \end{tikzpicture} \end{document}

  • Does the way LaTeX renders Greek letters have any special meaning when they look like regular letters?
    by FiveM on April 12, 2025 at 4:04 am

    I'm using a dataset of LaTeX code to generate images and train a model to predict the LaTeX code from those images, that is LaTex-OCR.The data I'm using is from this GitHub repo: GitHub - lukas-blecher/LaTeX-OCR. Right now, I'm in the middle of collecting the data, and I've noticed some issues with the code. So, I'm wondering if there's any meaning behind the code in the first equation. I've noticed that some of the code looks like the first example in the picture, and when it gets rendered, it looks kind of weird, as you can see. I looked it up online and even asked an AI, and they said the second example is the correct way to do it. Since this isn't my area of expertise, I'm asking you guys: Does the first way have some special meaning or is it a specific way of writing it? If not, is the second way the right one? By the way, the \boldmath command doesn't seem to work on Overleaf either. The first : { \bf E } _ { \omega } ( { \mathrm { \boldmath ~ \ v a r r h o ~ } } ) = - { \frac { 4 \pi i e } { v } } \ \int { \frac { { \bf q } _ { \bot } } { { \bf q } _ { \bot } ^ { 2 } } } \; F _ { p } ( { \bf q } ) \ \mathrm { e } ^ { i { \bf q } _ { \bot } { \mathrm { \scriptstyle \boldmath ~ \ v a r r h o ~ } } } \; { \frac { d ^ { 2 } q _ { \bot } } { ( 2 \pi ) ^ { 2 } } } \ . The second: { \bf E } _ { \omega } ( { \mathrm { \varrho } } ) = - { \frac { 4 \pi i e } { v } } \ \int { \frac { { \bf q } _ { \bot } } { { \bf q } _ { \bot } ^ { 2 } } } \; F _ { p } ( { \bf q } ) \ \mathrm { e } ^ { i { \bf q } _ { \bot } { \mathrm { \scriptstyle \varrho} } } \; { \frac { d ^ { 2 } q _ { \bot } } { ( 2 \pi ) ^ { 2 } } } \ . Thanks your advices,but I can't fine the way to render LaTex,I added to code.Apologize again.

  • How do I print the TeX code itself in the pdf while typeset by default?
    by dersu on April 12, 2025 at 1:59 am

    How can I typeset the code itself in the pdf while executing it? There is always a need doing so when I write LaTeX introduction articles or package help document. So far, I do it by copying the code in the verbatim environment. But it doubles my work and it’s hard to make sure that I renew the copy every time for consistency. And it’s not elegant by destroying the readability of the tex doc. For example: \documentclass[11pt]{article} \usepackage{musixtex} % music score \begin{document} How to draw a blank staff?\\ \begin{music} \startpiece \notes\en \zendpiece \end{music} \begin{verbatim} \begin{music} \startpiece \notes\en \zendpiece \end{music} \end{verbatim} \end{document}