• Align array elements by 1's digit
    by Jasper on April 19, 2025 at 12:11 am

    I am making arrays of numbers. How can I align them automatically by the one's 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}

  • Using more than one font for the same language with Polyglossia?
    by Brother Thurm on April 18, 2025 at 9:04 pm

    How do you use more than one font for the same language with Polyglossia? I need to use two different fonts for English and two different fonts for Ancient Greek. (So four fonts in total). The problem I’m having is that I do not always get the hyphenation features of Polyglossia when I use other fonts. Consider the following code: \documentclass[12pt]{article} \usepackage{fontspec} \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} \setmainfont{EB Garamond} % This is English font 1. \newfontfamily{\greekfont}[Script=Greek]{Old Standard} % This is Greek font 1. \newfontfamily\englishfonttwo{Gentium Book Plus} \DeclareTextFontCommand \englishtwo \englishfonttwo % This is English font 2. \newfontfamily{\greekfonttwo}[Script=Greek]{New Athena Unicode} \DeclareTextFontCommand \greektwo \greekfonttwo % This is Greek font 2. \usepackage{xunicode} \usepackage{polyglossia} \setdefaultlanguage{english} \setotherlanguage[variant=ancient]{greek} \usepackage{multicol} \setlength{\columnsep}{1.5cm} \begin{document} \begin{multicols*}{2} Greek Font 1\\ \textgreek{Θουκυδίδης Ἀθηναῖος ξυνέγραψε τὸν πόλεμον τῶν Πελοποννησίων καὶ Ἀθηναίων, ὡς ἐπολέμησαν πρὸς ἀλλήλους, ἀρξάμενος εὐθὺς καθισταμένου καὶ ἐλπίσας μέγαν τε ἔσεσθαι καὶ ἀξιολογώτατον τῶν προγεγενημένων, τεκμαιρόμενος ὅτι ἀκμάζοντές τε ᾖσαν ἐς αὐτὸν ἀμφότεροι παρασκευῇ τῇ πάσῃ καὶ τὸ ἄλλο Ἑλληνικὸν ὁρῶν ξυνιστάμενον πρὸς ἑκατέρους, τὸ μὲν εὐθύς, τὸ δὲ καὶ διανοούμενον.}\\ English Font 1\\ \textenglish{Thucydides, an Athenian, wrote the history of the war between the Peloponnesians and the Athenians, beginning at the moment that it broke out, and believing that it would be a great war, and more worthy of relation than any that had preceded it. This belief was not without its grounds. The preparations of both the combatants were in every department in the last state of perfection; and he could see the rest of the Hellenic race taking sides in the quarrel; those who delayed doing so at once having it in contemplation.}\\ Greek Font 2\\ \greektwo{Θουκυδίδης Ἀθηναῖος ξυνέγραψε τὸν πόλεμον τῶν Πελοποννησίων καὶ Ἀθηναίων, ὡς ἐπολέμησαν πρὸς ἀλλήλους, ἀρξάμενος εὐθὺς καθισταμένου καὶ ἐλπίσας μέγαν τε ἔσεσθαι καὶ ἀξιολογώτατον τῶν προγεγενημένων, τεκμαιρόμενος ὅτι ἀκμάζοντές τε ᾖσαν ἐς αὐτὸν ἀμφότεροι παρασκευῇ τῇ πάσῃ καὶ τὸ ἄλλο Ἑλληνικὸν ὁρῶν ξυνιστάμενον πρὸς ἑκατέρους, τὸ μὲν εὐθύς, τὸ δὲ καὶ διανοούμενον.}\\ English Font 2\\ \englishtwo{Thucydides, an Athenian, wrote the history of the war between the Peloponnesians and the Athenians, beginning at the moment that it broke out, and believing that it would be a great war, and more worthy of relation than any that had preceded it. This belief was not without its grounds. The preparations of both the combatants were in every department in the last state of perfection; and he could see the rest of the Hellenic race taking sides in the quarrel; those who delayed doing so at once having it in contemplation.} \end{multicols*} \end{document} The two English examples and the first Greek example work fine, but the second Greek example is really messed up. My guess is because it is within an English environment since that is the default language. So the \textgreek{} command must be putting its text into a Greek environment, while \greektwo{} is not. I understand that I can put the \greektwo{} command within Polyglossia’s Greek environment (by using \begin{greek}...\end{greek}) to get the hyphenation features, but I will be working in multiple columns with single words and small phrases of both Greek and English (The paragraphs in my MWE are to make the hypehnation problem more apparent and the code less cluttered). So I need to be able to use the \greektwo{} command within the English environment and still have Greek words hyphenated when they need to be. How, then, do I make \greektwo{} function just like \textgreek{} with the only difference being the font they print? I looked in the Fontspec and Polyglossia manuals, but couldn’t find anything dealing with this problem. It seems like there should be a simple solution to this; I’m still new to LaTeX, so I could have miss it. I apologize for such a long-winded post, but this problem is hard to explain. In short, I need all four fonts to be “connected” to Polyglossia, so that when I use the command for one I get the hyphenation features of that package. Thank you for your time and help.

  • Error: Missing number, treated as zero in listings packages
    by Udo on April 18, 2025 at 7:48 pm

    If I do this simple document, I get the Missing number, treated as zero error. The file main-97.asm has 97 lines, the file main-99 has 99 lines. Files with more then 98 lines don't work. \documentclass[a4paper]{article} \usepackage{german} \usepackage[ansinew,latin1,utf8]{inputenc} \usepackage{listings} \begin{document} % this is working %\lstinputlisting[breaklines]{main-97.asm} % this is not working \lstinputlisting[breaklines]{main-99.asm} \end{document} IN EQU 0x13 ; Eingänge The output: $ pdflatex lstlisting.tex This is pdfTeX, Version 3.141592653-2.6-1.40.27 (TeX Live 2025) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (./lstlisting.tex LaTeX2e <2024-11-01> patch level 2 L3 programming layer <2025-03-26> (/opt/texlive/2025/texmf-dist/tex/latex/base/article.cls Document Class: article 2024/06/29 v1.4n Standard LaTeX document class (/opt/texlive/2025/texmf-dist/tex/latex/base/size10.clo)) (/opt/texlive/2025/texmf-dist/tex/generic/german/german.sty v2.5e 1998-07-08) (/opt/texlive/2025/texmf-dist/tex/latex/base/inputenc.sty (/opt/texlive/2025/texmf-dist/tex/latex/base/ansinew.def) (/opt/texlive/2025/texmf-dist/tex/latex/base/latin1.def) (/opt/texlive/2025/texmf-dist/tex/latex/base/utf8.def (/opt/texlive/2025/texmf-dist/tex/latex/base/omsenc.dfu) (/opt/texlive/2025/texmf-dist/tex/latex/base/ot1enc.dfu) (/opt/texlive/2025/texmf-dist/tex/latex/base/t1enc.dfu) (/opt/texlive/2025/texmf-dist/tex/latex/base/ts1enc.dfu))) (/opt/texlive/2025/texmf-dist/tex/latex/listings/listings.sty (/opt/texlive/2025/texmf-dist/tex/latex/graphics/keyval.sty) (/opt/texlive/2025/texmf-dist/tex/latex/listings/lstpatch.sty) (/opt/texlive/2025/texmf-dist/tex/latex/listings/lstmisc.sty) (/opt/texlive/2025/texmf-dist/tex/latex/listings/listings.cfg)) (/opt/texlive/2025/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def) (./lstlisting.aux) (./main-99.asm (/opt/texlive/2025/texmf-dist/tex/latex/base/omlcmr.fd) [1{/opt/texlive/2025/texmf-var/fonts/map/pdftex/updmap/pdftex.map}{/opt/texlive /2025/texmf-dist/fonts/enc/dvips/cm-super/cm-super-ts1.enc}] (/opt/texlive/2025/texmf-dist/tex/latex/base/omscmr.fd) [2] ! Missing number, treated as zero. <to be read again> \global l.99 IN EQU 0x13 ; Eingänge ? ) ! Incomplete \iffalse; all text was ignored after line 99. <inserted text> \fi l.13 \lstinputlisting[breaklines]{main-99.asm} ? ) ! Incomplete \iffalse; all text was ignored after line 99. <inserted text> \fi <*> lstlisting.tex ? * For me it looks like somewhat can't count above 99 ?

  • TeX for Baire category iterative sequence construction
    by D.R on April 18, 2025 at 6:12 pm

    When I teach the Baire category theorem, I write on the board the following diagram: I would like to have a TeX version of this diagram. The easiest possible solution would be with arrays, but then I can’t get the long underbraces and diagonal $\in$ symbols. Maybe this requires tikz?

  • Is it possible to set the scale of predefined TikZ patterns?
    by Ferrous1 on April 18, 2025 at 5:53 pm

    Predefined TikZ patterns have always worked quite well for me, with one exception: I could never figure out how to set a specific "scale" or "zoom factor", so to say. Currently, I am creating graphs with shapes that span over the better part of an A4 page's width, hence in some cases, the provided patterns like north west lines are visually too dense. The following straightforward sketch visualizes what I would like to achieve, ideally without needing to create a pattern from scratch: MWE: \documentclass[margin=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{shapes,patterns} \begin{document} \begin{tikzpicture} \draw[pattern=north east lines] (0,0) rectangle ++(4,4); \end{tikzpicture} \end{document}

  • LaTeX compilation very slow
    by Alexandre Billon on April 18, 2025 at 5:41 pm

    On my new laptop (Chromebook with native Linux) LaTeX takes hours to complile documents. I have heard it is a problem of TEXTINPUT. when I type kpsexpand \$TEXINPUTS it says : .:{{}/home/abillon/.texlive2022/texmf-config,/home/abillon/.texlive2022/texmf-var,/home/abillon/texmf,!!/usr/local/share/texmf,/etc/texmf,!!/var/lib/texmf,!!/usr/share/texmf,!!/usr/share/texlive/texmf-dist}/tex/{kpsewhich,generic,latex,}// Does anyone know what I should do to avoid the problem.

  • Unable to get this chemfig
    by Karthick S on April 18, 2025 at 5:37 pm

    I have been trying to generate the following image for the last 5 hours without success: . Here is what I have till now: \documentclass{exam} \usepackage{amsmath} \usepackage{chemfig} \usepackage[version=4]{mhchem} \usepackage{graphicx} \usepackage[english]{babel} % If your document is in English \usepackage[utf8]{inputenc} % Make sure you have this \usepackage{tikz} \usetikzlibrary{positioning} %\usepackage{exam} % Uncomment if you want to use the exam class features \renewcommand{\thequestion}{A\arabic{question}} % Format as A<number> \renewcommand{\questionlabel}{\thequestion.} % Print A<number>. (Add the dot back) \begin{document} \begin{questions} \question \begin{parts} \part \begin{tikzpicture}[ node distance=2.5cm and 3.5cm, every node/.style={font=\small} ] % Compound P \node (P) {\chemfig{HO-[:0]-*6(=--(-NH_2)=-=)}}; \node[below=of P] (Q) {\chemfig{HO-[:0]-*6(=-(-N^{+}\equiv N^{-})-=-=)}}; \node[below=of Q] (S) {\chemfig{HO-[:0] -*6(=-- (-N=[:60]N -*6(= (-[::60]*6(=-= ( -OH )--=- ) )-=-=- ) )=-= ) }}; % Arrows \draw[->] (P) -- (Q) node[midway,right,xshift=1.2cm] {\chemfig{NaNO_2 + HCl}}; \draw[->] (Q) -- (S) node[midway,right,xshift=1.2cm] {\chemfig{NaOH + compound R}}; % Labels \node[left=1cm of P] {compound P}; \node[left=1cm of Q] {intermediate compound Q}; \node[left=1cm of S] {compound S}; \node[right=2.5cm of P] {First step in the synthesis:}; \node[right=2.5cm of Q] {Second step in the synthesis:}; \end{tikzpicture} \end{parts} \end{questions} \end{document} This generates the following image: Please help.

  • 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.

  • Strange space at pagebreak when with eqaution after the paragraph?
    by Explorer on April 18, 2025 at 4:42 pm

    I found that exist strange space at pagebreak with equation. normal case only with long paragraph text across pages: Empty Line(\par) between para. and equation \documentclass{article} \usepackage{lipsum} \usepackage{amsmath} \usepackage[showframe]{geometry} \begin{document} \lipsum[7-13] \begin{equation} \pi(w_i)=\frac{2\epsilon (w_i)}{\sum_{j=1}^{N_{\delta}}(w_i)} \end{equation} \end{document} No Empty Line(with nopar option) between para. and equation: \documentclass{article} \usepackage[nopar]{lipsum} \usepackage{amsmath} \usepackage[showframe]{geometry} \begin{document} \lipsum[7-13] \begin{equation} \pi(w_i)=\frac{2\epsilon (w_i)}{\sum_{j=1}^{N_{\delta}}(w_i)} \end{equation} \end{document} The content shrink. However, if I add more text, things go wrong again. \documentclass{article} \usepackage[nopar]{lipsum} \usepackage{amsmath} \usepackage[showframe]{geometry} \begin{document} I can eat the glass and it doesn't hurt me. I can eat the glass and it doesn't hurt me. I can eat the glass and it doesn't hurt me. I can eat the glass and it doesn't hurt me. I can eat the glass and it doesn't hurt me. I can eat the glass and it doesn't hurt me. \lipsum[7-13] \begin{equation} \pi(w_i)=\frac{2\epsilon (w_i)}{\sum_{j=1}^{N_{\delta}}(w_i)} \end{equation} \end{document} I'm not sure whether this is duplicated(but I feel hard to come up with keywords to hit them). I know that there is no reason for a equation to start a new paragraph, but in the last case, things still not behave well. It stuck me. My Questions: Why these strange spaces at pagebreaks happened? What's the best practice to handle equation after(or exactly, at the end of) the paragraph, that is, to prevent these spaces?

  • Cropping an Image to Fit in a Tikz Braided Frame
    by DDS on April 18, 2025 at 4:31 pm

    This post is related to How to Give an Elliptical Border a Braided Effect Consider the code: \documentclass[tikz, border=1cm]{standalone} \usepackage{graphicx} \begin{document} \begin{tikzpicture}[ line width=8.3pt, declare function={ rx=4.25; ry=5.5; n=10; da=180/n; ex1=(rx+0.2*cos(n*\t))*cos(\t); ey1=(ry+0.2*cos(n*\t))*sin(\t); ex2=(rx+0.2*cos(n*\t+120))*cos(\t); ey2=(ry+0.2*cos(n*\t+120))*sin(\t); ex3=(rx+0.2*cos(n*\t+240))*cos(\t); ey3=(ry+0.2*cos(n*\t+240))*sin(\t); }, samples=10, smooth, variable=\t, ] %\fill[black] \node at (0,0) {\includegraphics[page=1,scale=1.25,clip, trim = 0 0 0 0]{example-image}}; ellipse[radius=rx, y radius=ry]; \foreach \i [parse=true] in {0,...,(2*n-1)}{ \draw[orange!95!black] plot[domain=(\i-3/3)*da:(\i+0/3)*da+0.2] (ex1,ey1); \draw[orange!85!black] plot[domain=(\i-2/3)*da:(\i+1/3)*da+0.2] (ex2,ey2); \draw[orange!75!black] plot[domain=(\i-1/3)*da:(\i+2/3)*da+0.2] (ex3,ey3); } \clip (0,0) rectangle (rx,-ry); \foreach \i [parse=true] in {(2*n)}{ \draw[orange!95!black] plot[domain=(\i-3/3)*da:(\i+0/3)*da+0.2] (ex1,ey1); \draw[orange!85!black] plot[domain=(\i-2/3)*da:(\i+1/3)*da+0.2] (ex2,ey2); \draw[orange!75!black] plot[domain=(\i-1/3)*da:(\i+2/3)*da+0.2] (ex3,ey3); } \end{tikzpicture} \end{document} which produces QUESTION: How may I perfectly crop the image to the inside of the braided frame? Thank you.

  • Comma after the headings
    by filokalos on April 18, 2025 at 12:53 pm

    After compiling the code, a comma appears under the headings at the beginning of the next line: where is the error? % Шаблон ConTeXt для книги (А5, grid, Brill, мікротипографіка) \mainlanguage[ukrainian] % Шрифти та мова \definefontfamily [brill] [rm] [Brill] \definefontfeature [default] [default] [protrusion=quality, expansion=quality, lnum=yes] \setupbodyfont[brill,12pt] \setupbodyfontenvironment[default][interlinespace=4.7297mm] % Папір і поля \setuppapersize[A5][A5] \setuplayout[ location=middle, bleedoffset=5mm ] \setuplayout[ backspace=17mm, topspace=17mm, bottomspace=18mm, grid=yes ] % Вирівнювання і мікротипографіка \setupalign[hanging, hz, stretch, verytolerant] \setupinterlinespace[grid=yes] % Абзацні відступи \setupindenting[yes, small] \setupindenting[first, always] % Нумерація сторінок по краях \define[1]\CapPageNumber{\tfa\word{#1}} % цифри словами \setuppagenumbering[ alternative=doublesided, location={header,right}, command=\CapPageNumber ] % Команди стилю заголовків \define[1]\MyRomanChapterNumber{\blank\centerline{\tfa #1}\blank[small]} \define[1]\MyChapterTitle{\startnarrower[middle]\setupalign[middle,stretch]\tfa\bf #1\stopnarrower} \define[1]\MySectionTitle{\startnarrower[middle]\setupalign[middle]#1\stopnarrower} \define[1]\MySubsectionTitle{\startnarrower[middle]\setupalign[middle]#1\stopnarrower} \define[1]\MySubsubsectionTitle{\startnarrower[middle]\setupalign[middle]#1\stopnarrower} \setuphead[chapter][number=yes, conversion=R, numbercommand=\MyRomanChapterNumber, textcommand=\MyChapterTitle, style=\tfb\bf, before={\blank[2*big]}, after={\blank[force,big],\blank[force,overlay]}, indentnext=yes, align=middle] \setuphead[section][number=no, style=\tfa\bf, before={\blank[big]}, after={\blank[force,medium],\blank[force,overlay]}, textcommand=\MySectionTitle, indentnext=yes] \setuphead[subsection][number=no, style=\tf\bf, before={\blank[medium]}, after={\blank[force,small],\blank[force,overlay]}, textcommand=\MySubsectionTitle, indentnext=yes] \setuphead[subsubsection][number=no, style=\tfx\italic, before={\blank[small]}, after={\blank[force,small],\blank[force,overlay]}, textcommand=\MySubsubsectionTitle, indentnext=yes] % Макроси для сторінок без grid (титул, технічна) \define[1]\nonGridPage{ \startlayout[grid=no] \setupinterlinespace[reset] #1 \stoplayout } \starttext % --- Титул та технічна сторінки --- %\nonGridPage{\input titul} %\nonGridPage{\input technichna} % --- Основний текст по grid --- \chapter{Приклад глави} \section{Розділ} \subsection{Підрозділ} \subsubsection{Підпідрозділ} Це прикладовий текст глави. Тут можна писати довільний текст. Всі елементи вирівнюються по сітці (grid), використовується шрифт Brill із цифрами у вигляді капітелей. Ось другий абзац для прикладу. Він також матиме абзацний відступ, згідно з глобальним налаштуванням \type{\setupindenting[first, always]}. Це важливо для естетики друкованої сторінки та її зчитуваності. І третій абзац для демонстрації, що все працює як треба: сітка, мікротипографіка, відступи, стиль цифр та макети заголовків. \stoptext

  • Plot the cubic root function and its inverse
    by Dimitrios ANAGNOSTOU on April 18, 2025 at 12:06 pm

    I want to plot the cubic root function and its inverse. I use the following code: \documentclass[border=5pt]{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \begin{axis}[ width=0.8\textwidth, height=0.8\textwidth, axis equal, grid=both, xmin=-2, xmax=5, ymin=-2, ymax=5, axis lines=middle, xlabel={$x$}, ylabel={$y$}, legend pos=south east, legend style={draw=none}, ticklabel style={font=\scriptsize}, label style={font=\scriptsize}, legend style={font=\scriptsize} ] % Add unit vectors \draw[thick,-latex] (axis cs:0,0) -- (axis cs:0,1) node[midway, right, font=\scriptsize] {$\mathbf{j}$}; \draw[thick,-latex] (axis cs:0,0) -- (axis cs:1,0) node[midway, below, font=\scriptsize] {$\mathbf{i}$}; % Plot x^3 \addplot[ blue, domain=-2.5:2.5, samples=100, thick ] {x^3}; \addlegendentry{$x\mapsto x^3$} % Plot cubique(x) \addplot[ red, domain=0:2.5^3, samples=1000, thick ] {x^(1/3)}; \addlegendentry{$x\mapsto \sqrt[3]{x}=x^{1/3}$} % Plot y = x \addplot[ green, domain=-2.5:4.5, samples=100, dashed, thick ] {x}; \addlegendentry{$x\mapsto x$} % Plot cubique(x) pour les valeurs négatives \addplot[ red, domain=(-(2.5^3)):0, samples=2000, thick ] {-(-x)^(1/3)}; % Add the point (1.5, 3.3750) \node[circle,fill,inner sep=1.pt,label={[label distance=-1mm, font=\scriptsize] above right:{$(1.5, 3.375)$}}] at (axis cs:1.5,{1.5^3}) {}; % Add the point (3.3750, 1.5) \node[circle,fill,inner sep=1pt,label={[label distance=-1mm, font=\scriptsize] below :{$(3.375, 1.5)$}}] at (axis cs:3.375,1.5) {}; % Définition des points \coordinate (A) at (axis cs:1.5,3.375); \coordinate (B) at (axis cs:3.375,1.5); \coordinate (M) at (axis cs:{(1.5+3.375)/2},{(3.375+1.5)/2}); % Milieu de A et B % Traits pointillés entre A--M et M--B \draw[dashed] (A) -- (M); \draw[dashed] (M) -- (B); % Point M avec annotation \node[circle,fill,inner sep=1pt, label={[label distance=-1mm, font=\tiny] below:{$\left(\frac{1.5+3.375}{2}, \frac{3.375+1.5}{2}\right)$}}] at (M) {}; % Origine \node[label={[label distance=-1mm, font=\scriptsize] below left:{$O$}}] at (axis cs:0,0) {}; % Marque d'angle droit \draw ($(M)!2mm!(A)$) -- ++ ($($(M)!2mm!(axis cs:0,0)$)-(M)$) -- ($(M)!2mm!(axis cs:0,0)$); \end{axis} \end{tikzpicture} \end{document} I cannot understand the gap below: Any ideas to fix it (or even better to simplify the code)? Thanks!

  • Problem with more than one macros in tikz's foreach loop
    by gschaaf on April 18, 2025 at 12:05 pm

    I want to draw this image with tikz by using this code \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} % First matrix (4x3) \foreach \i in {0,...,2} { \pgfmathsetmacro{\value}{int(1+\i)} \draw (0,\i) rectangle ++(1,-1) node[midway] {\value}; \pgfmathsetmacro{\zeile}{int(3-\i)} \draw[<-,black] (1,1.5-\i) -- (2,1.5-\i) node[right] {\zeile. Zeile}; } \end{tikzpicture} \end{document} The numbers in the squares should be enumerated backwards: 3,2,1 and the rows (Zeilen) should be enumerated 1,2,3. However, the two macros are interfering and I end up with the same 3,2,1 order in both enumerations.

  • 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!

  • Highlight a specific author in citation call-outs
    by Roman Langrehr on April 18, 2025 at 7:54 am

    I am using bibtex with the alphaurl style and I want to highlight one author in the citation call-outs by making its letter bold, e.g. [ABC25]. The solution should only modify the .tex and the alphaurl.bst files, but not require any changes to the .bib file. I have found this solution, which highlights an author in the reference section, but does not modify the citation call-outs and this solution (with biblatex), which makes the entire citation call-out bold if a specific person co-authored the work. MWE: main.tex \documentclass{article} \begin{document} \cite{Test} showed something interesting. \bibliographystyle{alphaurl} \bibliography{add} \end{document} add.bib @inproceedings{Test, author = {Alice Allison and Bob Builder and Charlie Chaplin}, title = {On something interesting}, year = {2025} } Default result: Desired result:

  • Misplaced \noalign error when compiling table with \rowcolor and \multirow in booktabs
    by pvt on April 18, 2025 at 7:43 am

    I'm trying to create a formatted table using booktabs, multirow, and \rowcolor for highlighting some rows. However, when I compile my LaTeX file, I get the following error: Misplaced \noalign. You have used a \hline command in the wrong place, probably outside a table. If the \hline command is written inside a table, try including \\ before it. Here's a minimal example that produces the issue: \documentclass[final,3p,number]{elsarticle} \usepackage[dvipsnames, table]{xcolor} \usepackage{arydshln} \usepackage{booktabs} \usepackage{multirow} \usepackage{colortbl} \definecolor{lgreen}{RGB}{236, 255, 201} \definecolor{lightblue}{rgb}{0.678, 0.847, 0.902} \begin{document} \begin{table}[ht] \centering \caption{Pruning efficiency comparison} \label{tab:efficiency} \resizebox{\columnwidth}{!}{% \begin{tabular}{lllrrrrrr} \toprule \multirow{2}{*}{Model} & \multirow{2}{*}{Dataset} & \multirow{2}{*}{Method} & \multicolumn{3}{c}{Time cost (seconds)} & \multicolumn{3}{c}{Compression result} \\ \cmidrule(lr){4-6} \cmidrule(lr){7-9} & & & Phase 1 & Phase 2 & Total & Top-1 & MACs (CR) & Params (CR) \\ \midrule \multirow{3}{*}{Mo} & \multirow{3}{*}{Da} &\rowcolor{lightblue} M1 & 5387 & 1712 & 7099 & 93.08 & 82.81M (74) & 1.67M (89) \\ & &\rowcolor{lightblue} M2 & 810 & 3935 & 4745 & 93.68 & 66.95M (79) & 1.90M(87) \\ & &\rowcolor{lightblue} \textbf{M3} & \textbf{485} & \textbf{1548} & \textbf{2033} & \textbf{93.74} & \textbf{59.23M (81)} & \textbf{1.16M (92)} \\ \bottomrule \end{tabular}% } \end{table} \end{document} I suspect the issue may be related to the use of \rowcolor in combination with \multirow, or possibly the interaction with booktabs. How can I fix this error and keep the row coloring as intended?

  • Figure numbers are missing a trailing period within the main text
    by beebee on April 18, 2025 at 7:03 am

    Although this question may at first appear to have been answered, in reality this version is slightly different. I have been trying to add a period to the Figure numbers without specifying the additional \arabic{chapter} parameter within the class definition. That is, just using this line: \renewcommand{\thefigure}{\arabic{figure}} as opposed to doing something like this: \renewcommand{\thefigure} \arabic{chapter}.\arabic{section}} Here is a minimal example: \documentclass{usaalthesis} \usepackage{graphicx} \begin{document} \makefrontmatter \chapter{Introduction} \begin{figure} \centering \fbox{Diagram placeholder} \caption{Diagram} \label{fig:plot} \end{figure} See figure \ref{fig:plot}. \end{document} I have tried tweaking this \renewcommand within the class definition by manually adding a trailing period (.) after the figure argument like this: \renewcommand{\thefigure}{\arabic{figure}.} But while this appears to solve the problem (Refer to this screenshot:) , however, it also results in the entries on the list of figure entries having double periods following their respective numbers, like this "1..": . I have also played around with the \titleformat{}[] macros by trying to customize only the \figurename, \thefigure or \listfigurename or [display] parameters respectively, but this did not work. Further, I tried to use the key-value pair specifier [label=\arabic*.{thefigure}]. However, this has either resulted in errors or not worked altogether. Please, anyone with ideas that could resolve this issue? Thank you in advance. Addendum 1: Here is a minimal working example (MWE) of the thesis class: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{usaalthesis} \renewcommand{\thefigure}{\arabic{figure}} \RequirePackage{setspace} \newcommand*{\frontmatter}{ \pagenumbering{roman} } \newcommand*{\mainmatter}{\pagenumbering{arabic}} \newcommand*{\makelot}{} \newcommand*{\makelof}{} \newcommand*{\makelos}{} \newcommand*{\makeloa}{} \newcommand*{\maketoc}{ \ifdefined\pdfbookmark \phantomsection \pdfbookmark[1]{\contentsname}{TABLE OF CONTENTS} \renewcommand{\contentsname}{TABLE OF CONTENTS} \else \fi \tableofcontents \clearpage \newcommand*{\extravspace}[1]{\vspace{0in}} %% Setup a command to set spacing for body text... \newcommand*{\bodyspacing}{ \doublespacing } \newcommand*{\makefrontmatter}{ \bodyspacing \frontmatter\makesignaturepage\maketitlepage\makededication\makeacknowledgements\maketoc \makelot\makelof\makeloa\makelos\makemynom % %\makenomenclature \makeabstract \clearpage\mainmatter } \DeclareOption{lof}{\renewcommand*{\makelof}{ \ifdefined\phantomsection % makes hyperref recognize this section properly for pdf links \phantomsection \else \fi \renewcommand{\listfigurename}{LIST OF FIGURES} \addcontentsline{toc}{chapter}{\rm{LIST OF FIGURES}}\listoffigures \clearpage }} \usepackage[subfigure]{tocloft} % Alter the style of the Table of Contents \setlength{\cftafterloftitleskip}{0in} \renewcommand{\cftafterloftitle}{\hspace*{\fill} \\[\baselineskip]\mbox{}{\normalfont Figure}\hfill{\normalfont Page}} \renewcommand{\figurename}{LIST OF FIGURES} \renewcommand{\listfigurename}{LIST OF FIGURES\vspace{0.25 in}} \cftsetindents{figure}{0em}{3em} \counterwithout{figure}{chapter} \counterwithout{figure}{section} \renewcommand{\thefigure}{\arabic{figure}} %\titleformat{\thefigure}[display]{\normalfont\bfseries\centering\filcenter}{label=\arabic*.}{0em}{\ul} } And the MWE for the main.tex is: \documentclass[12pt, lot, lof]{usaalthesis} [12pt, lot, lof, los, loa] \usepackage[labelsep=period]{caption} \usepackage{graphics} \usepackage{graphicx} \newcommand{\inner}[2]{\langle #1 , #2 \rangle} \begin{document} \makefrontmatter \chapter{Introduction} \begin{figure} \centering \fbox{Diagram placeholder} \caption{Diagram} \label{fig:plot} \end{figure} See figure \ref{fig:plot}. \end{document} Addendum 2: The entire cls file: \NeedsTeXFormat{LaTeX2e} \ProvidesClass{usaalthesis} \RequirePackage{setspace} \newcounter{subyear} \setcounter{subyear}{\number\year} \def\submitted#1{\gdef\@submitted{#1}} \def\@submittedyear{\ifnum\month>10 \stepcounter{subyear}\thesubyear \else\thesubyear\fi} \def\@submittedmonth{\ifnum\month>10 January\else\ifnum\month>5 November \else June\fi\fi} \def\copyrightyear#1{\gdef\@copyrightyear{#1}} \def\@copyrightyear{\number\year} \def\adviser#1{\gdef\@adviser{#1}} \def\student#1{\gdef\@student{#1}} \long\def\@abstract{\@latex@error{No \noexpand\abstract given}\@ehc} \long\def\@mynom{\@latex@error{No \noexpand\nomenclature given}\@ehc} % Added by oao for nomenclature \newcommand*{\frontmatter}{ \pagenumbering{roman} } \newcommand*{\mainmatter}{\pagenumbering{arabic}} \newcommand*{\makelot}{} \newcommand*{\makelof}{} \newcommand*{\makelos}{} \newcommand*{\makeloa}{} \newcommand*{\maketoc}{ % Add ToC to the pdfbookmarks as a section, but not to the ToC itself. % only if we have the hyperref command that is necessary \ifdefined\pdfbookmark \phantomsection \pdfbookmark[1]{\contentsname}{TABLE OF CONTENTS} \renewcommand{\contentsname}{TABLE OF CONTENTS} % Added by oao \else \fi \tableofcontents \clearpage } %% Setup a command to add extra space only if in singlespacing mode \newcommand*{\extravspace}[1]{\vspace{0in}} %% Setup a command to set spacing for body text; also used to restore spacing after long tables in document \newcommand*{\bodyspacing}{ \doublespacing } %% Setup a command to set spacing for long tables, to be used manually in document \newcommand*{\tablespacing}{ \singlespacing } %% Command inserted into the document immediately after \begin{document} to place all frontmatter %% This was formerly named 'begincmd' and called below in \AtBeginDocument{} %% However, that is not compatible with package 'hyperref'. \tableofcontents needs %% to be declared from within the document itself. \newcommand*{\makefrontmatter}{ \bodyspacing \frontmatter\makesignaturepage\maketitlepage\makededication\makeacknowledgements\maketoc \makelot\makelof\makeloa\makelos\makemynom % Added by oao %\makenomenclature \makeabstract \clearpage\mainmatter } \def\@submitted{\@submittedmonth~\@submittedyear} \def\@authorreversed{[LastName, FirstName Middle]} \def\authorreversed#1{\gdef\@authorreversed{#1}} \def\@expectedgraddate{[Month Year]} \def\expectedgraddate#1{\gdef\@expectedgraddate{#1}} \def\@institution{[Institution]} \def\institution#1{\gdef\@institution{#1}} \def\@school{[College]} \def\school#1{\gdef\@school{#1}} \def\@dept{[Department]} \def\department#1{\gdef\@dept{#1}} \def\@degtit{[Degree Title]} \def\degreetitle#1{\gdef\@degtit{#1}} \def\@degtyp{[Degree Type]} \def\degreetype#1{\gdef\@degtyp{#1}} \def\@degabb{[Degree Abbreviation]} \def\degreeabbreviation#1{\gdef\@degabb{#1}} \def\@documenttype{[Document Type]} \def\documenttype#1{\gdef\@documenttype{#1}} \def\@documenttype{[Document Type]} \def\documenttype#1{\gdef\@documenttype{#1}} \def\@signatories{[Comma-Separated List of Signatories, Signatory 1, Signatory 2]} \def\signatories#1{\gdef\@signatories{#1}} \def\@priordegrees{[Comma-Separated List of Prior Degrees, Degree 2]} \def\priordegrees#1{\gdef\@priordegrees{#1}} \long\def\acknowledgements#1{\gdef\@acknowledgements{#1}} \long\def\bio#1{\gdef\@bio{#1}} \def\dedication#1{\gdef\@dedication{#1}} \usepackage{pgffor} \newcommand{\coverpage}[1]{ \newpage \thispagestyle{empty} { \topskip0pt \bfseries \vspace*{\fill} \begin{center}#1\end{center} \vspace*{\fill} } \clearpage \setcounter{page}{\numexpr \thepage-1 \relax} } \newcommand{\makesignaturepage}{{ \thispagestyle{empty} \singlespacing \begin{center} \MakeUppercase{\@institution} \\ \MakeUppercase{\@school} \\[1.5\baselineskip] \MakeUppercase{\@title} \\[\baselineskip] BY \\[0.8\baselineskip] \@author \\[1.5\baselineskip] \@documenttype \\[1.5\baselineskip] Submitted to the Graduate Faculty of \\ \@institution \\ in partial fulfillment of the requirements for the degree of \\[0.8\baselineskip] \@degtit \\[0.8\baselineskip] in \\[0.8\baselineskip] \@degtyp \\[0.8\baselineskip] \@expectedgraddate \\[0.8\baselineskip] \end{center} \noindent Approved: \hfill Date:\\[1.5\baselineskip] \foreach \signatory in \@signatories { \noindent \hrulefill \\ \noindent \signatory \\[\baselineskip] } \bodyspacing \clearpage }} \newcommand{\maketitlepage}{{ \thispagestyle{empty} \setcounter{page}{1} \singlespacing \begin{center} \vspace*{1.625in} \MakeUppercase{\@title} \\[4\baselineskip] \@documenttype \\[1.5\baselineskip] Submitted to the Graduate Faculty of \\ \@institution \\ in partial fulfillment of the \\ requirements for the degree of \\[2\baselineskip] \@degtit \\[0.8\baselineskip] in \\[0.8\baselineskip] \@degtyp \\[4\baselineskip] by \\ \@author \\ \foreach \priordegree in \@priordegrees { \priordegree \\ } \@expectedgraddate \end{center} \bodyspacing \clearpage }} \newcommand*{\makecopyrightpage}{ \thispagestyle{empty} \setcounter{page}{2} \vspace*{0in} \begin{center} \copyright\ Copyright by \@student, \@copyrightyear. \\ All rights reserved. \end{center} \clearpage} % Added by oao: \newcommand{\makemynom}{{ \phantomsection \addcontentsline{toc}{chapter}{\rm{NOMENCLATURE}} \chapter*{NOMENCLATURE} % \singlespacing % \noindent\@abstractopening \bodyspacing \@mynom }} \newcommand{\makeabstract}{{ \phantomsection \addcontentsline{toc}{chapter}{\rm{ABSTRACT}} \chapter*{ABSTRACT} \singlespacing \noindent\@abstractopening \bodyspacing \@abstract }} \newcommand{\makebio}{{ \phantomsection % makes hyperref recognize this section properly for pdf links \coverpage{BIOGRAPHICAL SKETCH} \addcontentsline{toc}{chapter}{\rm{BIOGRAPHICAL SKETCH}} \chapter*{BIOGRAPHICAL SKETCH} \@bio \clearpage }} \def\makeacknowledgements{ \ifx\@acknowledgements\undefined \else \chapter*{ACKNOWLEDGEMENTS} \@acknowledgements \clearpage \fi } \def\makededication{ \ifx\@dedication\undefined \else \vspace*{1.5in} \begin{center} \@dedication \end{center} \clearpage \fi } \DeclareOption{lot}{\renewcommand*{\makelot}{ \ifdefined\phantomsection % makes hyperref recognize this section properly for pdf links \phantomsection \else \fi \renewcommand{\listtablename}{LIST OF TABLES} % Added by oao (See p. 107 Kottwitz) \addcontentsline{toc}{chapter}{\rm{LIST OF TABLES}}\listoftables \clearpage }} \DeclareOption{lof}{\renewcommand*{\makelof}{ \ifdefined\phantomsection % makes hyperref recognize this section properly for pdf links \phantomsection \else \fi \renewcommand{\listfigurename}{LIST OF FIGURES} % Added by oao (See p. 107 Kottwitz) \addcontentsline{toc}{chapter}{\rm{LIST OF FIGURES}}\listoffigures \clearpage }} \DeclareOption{loa}{\renewcommand*{\makeloa}{ \ifdefined\phantomsection % makes hyperref recognize this section properly for pdf links \phantomsection \else \fi %\addcontentsline{toc}{chapter}{\rm{LIST OF ALGORITHMS}}\listofalg \clearpage }} \DeclareOption{los}{ \renewcommand*{\makelos}{ \phantomsection %\addcontentsline{toc}{chapter}{\rm{NOMENCLATURE}} %\printnomenclature \clearpage }} \DeclareOption{singlespace}{ \renewcommand*{\bodyspacing}{ \singlespacing } %% Add extra space only if in singlespacing mode \renewcommand*{\extravspace}[1]{\vspace{#1}} } %% Doublespacing is the default for the thesis -- need not be declared. \DeclareOption{doublespacing}{ \renewcommand*{\bodyspacing}{ \doublespacing } } \DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}} \ProcessOptions %% Not necessary to specify the point size - we inherit it from above %% \LoadClass[12pt]{report} \LoadClass{report} %%% Alter LaTeX defaults to try to eliminate all widows and orphans \clubpenalty=10000 \widowpenalty=10000 %%% try to avoid overfull lines by limiting how far it is okay to exceed the margins %%% http://www.tex.ac.uk/cgi-bin/texfaq2html?label=overfull \setlength{\emergencystretch}{2em} \long\def\mynom#1{\gdef\@mynom{#1}} %\long\def\abstractopening#1{\gdef\@abstractopening{#1}} % Added by oao \setlength{\emergencystretch}{2em} \long\def\abstract#1{\gdef\@abstract{#1}} \long\def\abstractopening#1{\gdef\@abstractopening{#1}} %% 'begincmd' no longer used -- insert \makefrontmatter in the document instead. See above. %\AtBeginDocument{\begincmd} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\ %%%% Tweak float placements \renewcommand{\topfraction}{0.85} % max fraction of floats at top \renewcommand{\bottomfraction}{0.6} % max fraction of floats at bottom % Parameters for TEXT pages (not float pages): \setcounter{topnumber}{2} \setcounter{bottomnumber}{2} \setcounter{totalnumber}{4} % 2 may work better \setcounter{dbltopnumber}{2} % for 2-column pages \renewcommand{\dbltopfraction}{0.66} % fit big float above 2-col. text \renewcommand{\textfraction}{0.15} % allow minimal text w. figs % Parameters for FLOAT pages (not text pages): \renewcommand{\floatpagefraction}{0.66} % require fuller float pages % N.B.: floatpagefraction MUST be less than topfraction !! \renewcommand{\dblfloatpagefraction}{0.66} % require fuller float pages \setlength{\textfloatsep}{30.0pt plus 1.0pt minus 1.0pt} \setlength{\floatsep}{30.0pt plus 1.0pt minus 1.0pt} %%% ToC (table of contents) APPEARANCE %\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC \usepackage[subfigure]{tocloft} % Alter the style of the Table of Contents \setcounter{tocdepth}{5} \setcounter{secnumdepth}{5} \renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape} \renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} \renewcommand{\cftchapfont}{\rmfamily\mdseries\upshape}% No bold! \renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}} \renewcommand{\cftchappagefont}{\small\normalfont} \let \savenumberline \numberline \def \numberline#1{\savenumberline{#1.}} %%% TODO auto-generate this from the algorithm caption somehow \newcommand\listalgoname{LIST OF ALGORITHMS\vspace{0.25 in}} \newlistof{alg}{loalgo}{\listalgoname} \newcommand{\alg}[1]{% \refstepcounter{alg}% \addcontentsline{loalgo}{figure} {\protect\numberline{\thealg}#1}\par% } \renewcommand{\cfttoctitlefont}{\hspace*{\fill}\normalsize\bfseries} \renewcommand{\cftlottitlefont}{\hspace*{\fill}\normalsize\bfseries} \renewcommand{\cftloftitlefont}{\hspace*{\fill}\normalsize\bfseries} \renewcommand{\cftloalgotitlefont}{\hspace*{\fill}\normalsize\bfseries} \setlength{\cftaftertoctitleskip}{0in} \setlength{\cftafterloftitleskip}{0in} \setlength{\cftafterlottitleskip}{0in} \setlength{\cftafterloalgotitleskip}{0in} \renewcommand{\cftafterlottitle}{\hspace*{\fill} \\[\baselineskip]\mbox{}{\normalfont Table}\hfill{\normalfont Page}} \renewcommand{\cftaftertoctitle}{\hspace*{\fill} \\[\baselineskip]\mbox{}\hfill{\normalfont Page}} \renewcommand{\cftafterloftitle}{\hspace*{\fill} \\[\baselineskip]\mbox{}{\normalfont Figure}\hfill{\normalfont Page}} \renewcommand{\cftafterloalgotitle}{\hspace*{\fill} \\[\baselineskip]\mbox{}{\normalfont Algorithm}\hfill{\normalfont Page}} \renewcommand*\contentsname{TABLE OF CONTENTS} %change toc name \renewcommand*\listtablename{LIST OF TABLES\vspace{0.25 in}} \renewcommand{\figurename}{LIST OF FIGURES} \renewcommand{\listfigurename}{LIST OF FIGURES\vspace{0.25 in}} \renewcommand\bibname{REFERENCES\vspace{0.25 in}} \providecommand{\e}[1]{\ensuremath{\times 10^{#1}}} \cftsetindents{figure}{0em}{3em} \cftsetindents{table}{0em}{3em} \cftsetindents{chapter}{0em}{2em} \cftsetindents{section}{2em}{3em} \cftsetindents{subsection}{4em}{4em} \cftsetindents{subsubsection}{6em}{5em} %\renewcommand{\cftfigaftersnum}{.} \setlength{\cftchapnumwidth}{7.5em} \let\oldcftchappresnum\cftchappresnum \renewcommand*{\cftchappresnum}{CHAPTER \oldcftchappresnum} %%% HEADERS & FOOTERS \usepackage{fancyhdr} % This should be set AFTER setting up the page geometry \pagestyle{fancy} % options: empty , plain , fancy \renewcommand{\headrulewidth}{0pt} % customize the layout... \lhead{}\chead{}\rhead{} \lfoot{}\cfoot{\thepage}\rfoot{} %%%%Nomenclature \usepackage[nocfg]{nomencl} \let\oldnomenclature\nomenclature \renewcommand{\nomenclature}[2]{\oldnomenclature{\hbox to 0.2\textwidth{#1}#2}{}} \let\oldnompreamble\nompreamble \renewcommand{\nompreamble}{\vspace*{0.4in}\oldnompreamble} %%%%Bibliographic style \let\oldbibliography\bibliography \renewcommand{\bibliography}[1]{ \phantomsection % makes hyperref recognize this section properly for pdf link \coverpage{REFERENCES} \singlespacing \renewcommand{\bibname}{REFERENCES} % Added by oao \addcontentsline{toc}{chapter}{\rm{REFERENCES}} \oldbibliography{#1} \bodyspacing } %%%%Appendix style \let\oldappendix\appendix \renewcommand{\appendix}{ \phantomsection \coverpage{APPENDICES} \renewcommand{\thesection}{\Alph{section}} \addcontentsline{toc}{chapter}{\rm{APPENDICES}} \let\oldcftsecpresnum\cftsecpresnum \addtocontents{toc}{% \protect\setlength{\cftsecnumwidth}{7.5em}% \protect\renewcommand*{\protect\cftsecpresnum}{Appendix \oldcftsecpresnum}% } \titleformat{\section}[display]{\normalfont\bfseries\centering}{APPENDIX \thesection}{0pt}{} \titlespacing*{\section}{0pt}{1\baselineskip}{1\baselineskip} \oldappendix } %%% Is this not the default? \raggedright %%%chapter titles and stuff \usepackage[largestsep]{titlesec} \usepackage{chngcntr} \counterwithout{figure}{chapter} \counterwithout*{figure}{section} \counterwithout{table}{chapter} \counterwithout{table}{section} \titlespacing*{\chapter}{0pt}{1in}{20pt} \titlespacing*{\section}{0pt}{1\baselineskip}{0pt} \titlespacing*{\subsection}{0pt}{\ifnum\value{subsection}<2 1\baselineskip \else 0pt \fi}{0pt} \titlespacing*{\subsubsection}{0pt}{0pt}{0pt} \titlespacing*{\subsubsubsection}{0pt}{0pt}{0pt} \titlespacing*{\thebibliography}{0pt}{1in}{20pt} \renewcommand{\thechapter}{\Roman{chapter}} \renewcommand{\chaptername}{CHAPTER} \renewcommand{\thesection}{\arabic{chapter}.\arabic{section}} %\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}} %\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}} % See link for details: https://tex.stackexchange.com/questions/411708/add-period-in-list-of-figures-list-of-tables %\renewcommand{\thetable}{\arabic{chapter}.\arabic{section}} %\renewcommand{\thefigure}{\arabic{figure}} %\renewcommand{\thefigure}{\arabic{figure}} %\renewcommand{\thefigure}[label=\arabic*{\thefigure}] \renewcommand{\thetable}{\arabic{table}} \titleformat{\chapter}[display]{\normalfont\bfseries\centering\filcenter}{\MakeUppercase{\chaptertitlename} \thechapter}{0pt}{\MakeUppercase} % OAO: Modified the default Chapter heading/title from initial caps to all caps. Courtesy link: https://tex.stackexchange.com/questions/630900/center-uppercase-chapter-title-with-titlesec \titleformat{\section}[hang]{\small\bfseries\centering}{\ul{\thesection \enspace}}{0em}{\ul} \titleformat{\subsection}[hang]{\small\bfseries\centering}{\thesubsection}{0.33em}{} \titleformat{\subsubsection}[hang]{\small\bfseries}{\ul{\thesubsubsection \enspace}}{0em}{\ul} %\titleformat{\thefigure}[display]{\normalfont\bfseries\centering\filcenter}{label=\arabic*.}{0em}{\ul} % create an environment that will indent text % see: http://latex.computersci.org/Reference/ListEnvironments % \raggedright makes them left aligned instead of justified \newenvironment{indenttext}{ \begin{list}{}{ \itemsep 0in \itemindent 0in \labelsep 0in \labelwidth 0in \listparindent 0in \topsep 0in \partopsep 0in \parskip 0in \parsep 0in \leftmargin 1em \rightmargin 0in \raggedright } \item } {\end{list}} % another environment that`s an indented list, with no spaces between items -- if we want multiple items/lines. Useful in tables. Use \item inside the environment. % \raggedright makes them left aligned instead of justified \newenvironment{indentlist}{ \begin{list}{}{ \itemsep 0in \itemindent 0in \labelsep 0in \labelwidth 0in \listparindent 0in \topsep 0in \partopsep 0in \parskip 0in \parsep 0in \leftmargin 1em \rightmargin 0in \raggedright } } {\end{list}} \setlength{\parindent}{3em} \usepackage[top=1in, bottom=1.25in, left=1.5in, right=1in]{geometry} \setlength{\footskip}{0.625in} \endinput %% %% End of file `usaalthesis.cls'.

  • 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

  • titlesec: Print title rule "bottom" or "top and bottom" based on conditions
    by edjmir on April 18, 2025 at 6:20 am

    I'd like to enclose subsection between \titlerule but I don't know how to avoid duplicating a line if a section is followed by a subsection. \documentclass{article} \usepackage{lipsum} \usepackage{titlesec} \usepackage[ letterpaper, top=35mm, bottom=25mm, right=20mm, left=20mm ]{geometry} %%%%%%%%%%%%%%%%%%%%%%%% % Config \setlength{\parindent}{0pt} \setlength{\parskip}{0.5em} \setlength{\smallskipamount}{4pt plus 1pt minus 1pt} \setlength{\medskipamount}{8pt plus 3pt minus 3pt} \setlength{\bigskipamount}{24pt plus 8pt minus 8pt} \titleformat{\section}{\scshape\Large\raggedright\uppercase}{}{0em}{}[\titlerule] \titleformat{\subsection}{\scshape\centering}{}{0em}{\titlerule}[\titlerule] \titlespacing{\section}{0pt}{\smallskipamount}{\smallskipamount} \titlespacing{\subsection}{0pt}{\smallskipamount}{\smallskipamount} %%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%% % Command %%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \section*{Hello world} \begin{paragraph} \centering \lipsum[1] \end{paragraph} \subsection*{My title} \lipsum[1] \section*{Hello world} \subsection*{My title} \lipsum[1] \subsection*{My title} \lipsum[1] \end{document}

  • TikZ: Floating xbars not starting at 0
    by Ludger on April 18, 2025 at 4:55 am

    I've just spent the past ~hour digging through the pgfplots documentation, and Stackoverflow but have not been able to find an example of a floating bar chart, where individual bars do not start at 0. What I am looking to accomplish is something like this: I.e. if the specific bar finishes at e.g. 0.7, I want it to start at a value greater than 0. Here is a MWE, in which the bars presently start at 0, but where I would want them to start at e.g. 0.05. Thank you so much for all the help! \documentclass[crop,tikz]{standalone} \usepackage{pgfplots} \usepackage{tikz} \pgfplotsset{compat=1.17} \begin{document} \begin{tikzpicture} \begin{axis}[symbolic y coords={cat1, cat2}] \addplot [xbar] coordinates {(0.3,cat1)}; \addplot [xbar] coordinates {(0.7,cat2)}; \end{axis} \end{tikzpicture} \end{document} (The number of y-axis labels can be ignored)

  • `\afterpage` with `twocolumn` class option [duplicate]
    by myhsia on April 18, 2025 at 3:46 am

    In a twocolumn document, I'd like to specific a different geometry on the first page, so I use \afterpage: We know that \restoregeometry will start a new page, but \afterpage makes the \restoregeometry execute at the end of the first column, not the end of the first page. How can I make it execute at the end of the first page? \documentclass[twocolumn]{article} \usepackage{geometry, afterpage, lipsum} \geometry{margin = 1in} \begin{document} \newgeometry{margin = 1.5in} \afterpage{\aftergroup \restoregeometry} \lipsum[1-6] \end{document}

  • 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

  • Spreadtab in new environment, package tabularray Error: Unknown outer key name '1'
    by Steven on April 17, 2025 at 7:56 pm

    Let me be the first to address this; this is not a duplicate of this question, rather a follow-up. The answer in the question contains a solution that has worked for me for a while, but recently I used my "old" code again and I now consistently get this error: ! Package tabularray Error: Unknown outer key name '1'. I noticed there have been some updates to the packages recently, I wonder if that might've caused it. Considering the error appears only when I make use of my new environment (see MWE below), I suspect it's related to that. Can someone help me resolve this issue? MWE: \documentclass{article} \usepackage{tabularray} \usepackage{spreadtab} \usepackage{environ} \begin{document} % This works \begin{spreadtab}{{tblr}{ colspec = {XXX}, hlines,vlines }} @ Description & @ Value 1 & @ Value 2 \\ @ Item 1 & 1 & 2 \\ @ Item 2 & 3 & 4 \\ @ Total & sum(b2:[0,-1]) & sum(c2:[0,-1]) \end{spreadtab} % Define it as I used to \NewEnviron{book}[2][1]{% \edef\x{% \unexpanded{ \begin{spreadtab}{{tblr}[#1]{#2}} } \unexpanded\expandafter{\BODY} \unexpanded{ \end{spreadtab} } }\x } % Try it \begin{book}{ colspec = {XXX}, hlines,vlines } @ Description & @ Value 1 & @ Value 2 \\ @ Item 1 & 1 & 2 \\ @ Item 2 & 3 & 4 \\ @ Total & sum(b2:[0,-1]) & sum(c2:[0,-1]) \end{book} \end{document}

  • input header with ltablex adds unwanted space
    by Br1ghT3x on April 17, 2025 at 7:31 pm

    I'm using ltablex to create a multi-page table. I import the header using input. However, an unwanted space is created below the header: tableheader.tex header1 & header2 & header3\\ \hline\endinput% main.tex \documentclass{report} \usepackage{ltablex} \begin{document} \begin{tabularx}{\linewidth}{XXX}% \input{tableheader}% \endfirsthead% test & & \\ \hline test & & \\ \hline \end{tabularx} \end{document} Some observations: I have tried the usual tricks with % and \unskip, but I can't eliminate the space. When I move \endfirsthead to the tableheader.tex, the issue does not occur (not an option since this header is used multiple times in my documents). Same problem with \endhead (which is not used in my MWE)

  • 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}

  • ConTeXt: adjust interword space for letterspacing
    by impresso on April 17, 2025 at 4:51 am

    I find that ConTeXt's letterspacing command does not adjust the interword space the way I'd expect it to. As the letterspacing factor grows, it gets hard to tell words apart, as the spaces between letters and between words become of similar size. (Perhaps it is simply adding the same space factor to both.) Is this by design? And if so, is there a way to tweak the interword space, to compensate? (The ConTeXt wiki tells me that \definecharacterkerning takes some extra parameters, but I can't quite tell what they do.) I'm using ConTeXt MkXL 2025.04.01 12:45. Edit: To give an example, the chapter titles of Bringhurst's Elements of Typographical Style look something like this (I've eyeballed it, and bear in mind the original uses a different, non-free, font): Using the same factor in ConTeXt's \letterspacing, however, yields which is not as legible IMO, and even less so for bigger spacing factors. But Max Chernoff's answer is workable, and I'll gladly accept it if there's no proper "ConTeXt-y" solution. Thanks! \setupbodyfont[ebgaramond] \startTEXpage[offset=1em] %{\spaceskip=.33em \letterspacing[.16]{THE GRAND DESIGN}} \letterspacing[.16]{THE GRAND DESIGN} \stopTEXpage