• Hairpins decrescendo horizontal width not working in Musixtex
    by ABV on September 7, 2026 at 3:46 pm

    It is needed to implement Hairpins decrescendo with custom horizontal width in Musixtex. The basic code is as follow: \documentclass[12pt]{article} % ========== FORMATO DE PÁGINA: A4 VERTICAL ========== \usepackage[a4paper,portrait,left=0.4cm,right=0.2cm,top=0.2cm,bottom=0.2cm]{geometry} \pagestyle{empty} % ========== PAQUETES ========== \usepackage{tikz} \usetikzlibrary{quotes} \usetikzlibrary{shapes} \usetikzlibrary{fit,positioning} \usetikzlibrary{arrows.meta} \usetikzlibrary{decorations} \usepackage{amsmath} \usepackage{xcolor} \usetikzlibrary{calc} \usepackage{musicography} \usepackage{musixtex} \input musixper \input musixlyr \input musixjt %\input musixps \xdefinecolor{red-undar}{RGB}{179,35,79} \begin{document} \begin{music} \centerline{\Bigtype R\,A\,Í\,C\,E\,S\,\,\,\,\,\,\,D\,E\,L\,\,\,\,\,\,\,F\,E\,S\,T\,E\,J\,O} \vskip1ex % ========== CONFIGURACIÓN GLOBAL ========== \parindent15mm% \staffbotmarg9\Interligne \font\B=phvb8t at 12pt \font\A=phvb8t at 10pt \A% \setsongraise1{7mm} \setstaffs1{1} \setlines{1}{5} \setclef{1}{\treble} \setclefsymbol{1}{\drumclef}% \generalmeter{\meterfrac{12}8}% \setname1{% \begin{tikzpicture}[baseline] \node[align=center, font=\A, inner sep=0pt, yshift=4mm] {Cajón\\Peruano}; \end{tikzpicture}% } %\nobarnumbers% \systemnumbers% \def\raisebarno{5\internote}% % acerca el número al pentagrama \def\shiftbarno{-5pt}% % posición horizontal \def\writebarno{\eightrm\the\barno\barnoadd}% quita el recuadro, usa texto simple \startrule % ancho de sistema = ancho del texto de la página A4 (sin sobreancho) % ========== SISTEMA 1 (6 compases) ========== %\setcrescheight{-7\Internote} \startpiece \notes\usf p\ibu0i0\qb0{fj}\tbu0\qb0f\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en%\bar \notes\ibl0i0\qb0{j}\tbl0\qb0j\ds\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en\bar%Fin motivo Festejo %Inicio motivo Festejo \notes\icresc\usf p\ibu0i0\qb0{fj}\tbu0\qb0f\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en%\bar \notes\ibl0i0\qb0{j}\tbl0\qb0j\ds\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en\bar%Fin motivo Festejo %Inicio motivo Festejo \notes\usf p\ibu0i0\qb0{fj}\tbu0\qb0f\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en%\bar \notes\ibl0i0\qb0{j}\tbl0\qb0j\ds\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en\bar%Fin motivo Festejo %Inicio motivo Festejo \notes\usf p\ibu0i0\qb0{fj}\tbu0\qb0f\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en%\bar \notes\ibl0i0\qb0{j}\tbl0\qb0j\ds\en%\bar \notes\ibu0i0\qb0{f}\tbu0\qb0f\ds\en% \znotes\raisebox{-20pt}{\tdecresc}\en\setdoubleBAR% \nolyr% \lyricsoff% \endpiece% \end{music} \end{document} The current output is as follow: The desired output is as follow: Note: notices that the width of the decrescendo hairpins should be at the end of the system.

  • Selecting fonts for individual alphabets with `lua-unicode-math`
    by moro11 on September 7, 2026 at 3:42 pm

    At the moment i probably wont switch to lua-unicode-math but i tried it out a little and stumbled across a problem i would like to address: setting specific fonts seems not to be supported by \setmathfont. Consider the following examples \documentclass{standalone} \usepackage{fontspec} \usepackage{lua-unicode-math} \setmathfont{STIX Two Math} \setmathfont[range={scr,bfscr}, StylisticSet=1]{STIX Two Math} \begin{document} $A \mathcal{A} \mathscr{A}$ \end{document} \documentclass{standalone} \usepackage{fontspec} \usepackage{lua-unicode-math} \setmathfont{STIX Two Math} \setmathfont[version=bold]{NewCMMath-Bold} \begin{document} $A$ {\boldmath$A$} \end{document} It is clear, that in the first example, not only \symscr but also \symcal (and i would assume all fonts) are replaced by the second call of \setmathfont, while in the second example we have the same problem, where not just the bold version but all fonts are replaced by the second call. Of course, this setup (in particular the option range and version) is just copy pasted from a typical unicode-math setup and there is no reason why the \setmathfont command provided by lua-unicode-math should take the same arguments at the \setmathfont command provided by unicode-math. But considering that the documentation of lua-unicode-math is very thin at the moment and only, there is not much information available on how to configure your fonts. Thus, i choose these setups to express what i would like to do (not stating that i expect it to work like that). Thus, to my main question: what is the intended way to fine tune your font setup manually, beyond loading a pre-defined setup via \usepackage{lmu-<some provided font>}?

  • How to Insert a Minipage into a Table of Contents?
    by Jethro on September 7, 2026 at 3:29 pm

    MWE: \documentclass[12pt]{book} \begin{document} \addtocontents{toc}{\protect\centering I would like to convert this into a centered minipage, say 3in. in width; however, I have been unable to make use of a minipage with the addtocontents command. \par} % % THIS DOES NOT WORK. %\addtocontents{toc}{\protect\centering \begin{minipage}{3in} I would like to convert this into a centered minipage, say 3in. in width; however, I have been unable to make use of a minipage with the addtocontents command. \end{minipage} \par} \tableofcontents \end{document} The output:

  • Aliyaphone khanti [closed]
    by Aliyaphone Kt on September 7, 2026 at 12:57 pm

    \documentclass[11pt, a4paper]{article} % --- Packages --- \usepackage[utf8]{utf8} \usepackage[margin=1in]{geometry} % Set margins to 1 inch \usepackage{titlesec} % Customizing section headers \usepackage{enumitem} % Customizing lists \usepackage{hyperref} % Hyperlinks for email/phone \usepackage{xcolor} % Styling colors % --- Page Setup --- \pagestyle{empty} % Disable page numbers and headers/footers % --- Hyperlink Setup --- \hypersetup{ colorlinks=true, linkcolor=black, urlcolor=black } % --- Custom Section Formatting --- % Bold UPPERCASE main headings with a horizontal line beneath \titleformat{\section} {\large\bfseries\scshape\uppercase} % Style: Large, Bold, Small Caps, Uppercase {} % Label {0pt} % Sep {} % Before code [\titlerule] % Horizontal rule under title \titlespacing*{\section}{0pt}{12pt}{8pt} % --- Custom Commands --- % Command for entry headers with right-aligned dates \newcommand{\resumeEntry}[4]{ \noindent \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r} \textbf{#1} & \textit{#2} \\ \textit{#3} & \textit{#4} \\ \end{tabular*}\vspace{-4pt} } \begin{document} % ========================================== % HEADER / CONTACT INFORMATION % ========================================== \begin{center} {\Huge \bfseries Aliyaphone Khanti} \\[6pt] \small Changkhou Village, Xaithany District, Vientiane Capital, Laos \\ Phone: \href{tel:+8562056305551}{+856 20 56305551} \quad$\cdot$\quad Email: \href{mailto:Aliyaphone241@gmail.com}{Aliyaphone241@gmail.com} \end{center} \vspace{10pt} % ========================================== % PROFESSIONAL SUMMARY % ========================================== \section{Professional Summary} Enthusiastic and community-minded professional with a strong background in environmental volunteering and teaching support. Passionate about sustainable development, community engagement, and youth education. Possesses excellent communication and public speaking skills with a proven ability to lead and collaborate effectively. % ========================================== % EXPERIENCE % ========================================== \section{Experience} \resumeEntry{Teaching Assistant (English)}{Hometown, Laos}{Local Community School}{Dates} \begin{itemize}[leftmargin=1.5em, itemsep=2pt] \item Assisted primary English teachers in preparing lesson materials, conducting interactive classroom activities, and supporting student learning. \item Helped students improve their English pronunciation, vocabulary, and basic communication skills through small-group discussions and tutoring. \item Fostered an encouraging and engaging learning environment tailored to students' needs. \end{itemize} % ========================================== % VOLUNTEER WORK & PROJECTS % ========================================== \section{Volunteer Experience} \resumeEntry{Volunteer Coordinator / Participant}{Vientiane, Laos}{"Dek Xang Sang Phan" Environmental Project}{Dates} \begin{itemize}[leftmargin=1.5em, itemsep=2pt] \item Participated in environmental awareness campaigns and educational workshops aimed at promoting youth development and sustainability. \item Collaborated with local volunteers to organize community activities and outreach programs. \end{itemize} \vspace{4pt} \resumeEntry{Project Volunteer}{Laos / Regional}{"AEC Goes Green" Initiative}{Dates} \begin{itemize}[leftmargin=1.5em, itemsep=2pt] \item Contributed to regional environmental initiatives focused on eco-friendly practices, waste reduction, and green sustainability in the AEC community. \item Engaged with local communities to advocate for environmental conservation and green practices. \end{itemize} % ========================================== % SKILLS % ========================================== \section{Skills \& Competencies} \begin{itemize}[leftmargin=1.5em, itemsep=2pt] \item \textbf{Communication Skills:} Excellent verbal and written communication abilities; experienced in cross-cultural and community interaction. \item \textbf{Public Speaking:} Confident presenting to groups, facilitating workshops, and conducting educational sessions. \item \textbf{Interpersonal Skills:} Teamwork, leadership, adaptability, problem-solving, and community outreach. \item \textbf{Languages:} Lao (Native), English (Proficient). \end{itemize} % ========================================== % EDUCATION % ========================================== \section{Education} \resumeEntry{High School Diploma / Degree Title}{Graduation Year}{School / Institution Name}{Location} \end{document}

  • `flalign` equations inside a `algorithm2e` are slightly indented
    by Thibault de Villèle on September 7, 2026 at 10:19 am

    Take the following MWE: \documentclass{article} \usepackage[ruled]{algorithm2e} \usepackage{amsmath, mathtools}% mathtools for \mathllap... \begin{document} \begin{algorithm}[h]% \DontPrintSemicolon% \SetKwComment{Comment}{(\,}{\,)}% \KwIn{\(C\), a matrix}% \( C \gets \mathrm{Id}(3) \)\;% % Reduce above/below skips to show the mis-alignment: \setlength{\abovedisplayskip}{-4.5pt plus 0.5pt minus 0.5pt}% \setlength{\belowdisplayskip}{-4.5pt plus 0.5pt minus 0.5pt}% \setlength{\abovedisplayshortskip}{-4.5pt plus 0.1pt minus 0.1pt}% \setlength{\belowdisplayshortskip}{-4.5pt plus 0.1pt minus 0.1pt}% \begin{flalign*}% C &\gets \mathrm{Id}(3) && \mathllap{\Comment*[f]{Should not be indented}}% \end{flalign*}\;% \Return{\(C\)}% \caption{\AmS\ example.}% \end{algorithm} \end{document} Produces (LuaLaTeX, TeXlive 2026): I'd expect the text-style equation (between \( ... \)) to be aligned with the display-style one right below. However, even with a flalign environment, it seems a slight left margin (skip?) is added to flalign environments. How could I get rid of it? I have a few such use cases of this flalign* + \Comment environment in my document, and they all have that indentation.

  • Blockwise random order of questions (with answers) using mcexam
    by Tripedior on September 7, 2026 at 9:10 am

    This is a follow-up question to Blockwise random order of questions using mcexam: I would like to randomize the order of questions of each field, but not shuffle questions of different fields together using the mcexam package. The questions should be consecutively numbered (1,2,3,4 in the MWE). My actual application of course has more than two questions in each block, and also more than two blocks. As was already suspected in the answer to that question, there unfortunately are problems when also providing answers to the questions. Answers themselves are already a problem, but things seem to behave even more unpredictably when using the [correct] argument: When using output=exam, the mc@counter seems to correspond to the number of answer options When using output=answers, the mc@counter seems to correspond to the number of the correct answer in the list AFTER randomization I have disabled randomizequestions for now, to remove one factor from the equation (but the idea is to activate it again in the future). My suspicion is that the mc@counter is also used for something related to answers and, thus, the suggestion in the previous question regarding the blockwise random order breaks at this point. Attached you find a new MWE (I added an output of the value of resumequestions to the end hook of the mcquestions environment for debugging purposes). Edit: I would also need questions with more than one correct answer, i.e., where more than one answer gets the [correct] argument. \documentclass[a4paper]{article} \usepackage[ numberofversions=1, seed=11, randomizequestions=false, randomizeanswers=true, writeRfile=false, ]{mcexam} \mcexamoptions{output=answers} %\mcexamoptions{output=exam} \newcounter{resumequestions} \setcounter{resumequestions}{0} \makeatletter \AddToHook{env/mcquestions/end}{\addtocounter{resumequestions}{\value{mc@counter}}Value of resumequestions: \the\value{resumequestions}} \makeatother \renewcommand\mcquestionlabelfmt[1]{\addtocounter{setmcquestionsi}{\value{resumequestions}}\arabic{#1}\addtocounter{setmcquestionsi}{-\value{resumequestions}}} \begin{document} \begin{mcquestions} % First block of questions (1-2, ordered randomly in the future using randomizequestions=true) \question How much is $3+2$? \begin{mcanswerslist} \answer a \answer b \answer c \end{mcanswerslist} \question How much is $2+2$? \begin{mcanswerslist} \answer a \answer b \answer c \answer[correct] d \answer e \answer f \end{mcanswerslist} \end{mcquestions} \begin{mcquestions} % Second block of questions (3-4, ordered randomly in the future using randomizequestions=true) \question Is John Doe alive? \begin{mcanswerslist} \answer a \answer b \answer c \end{mcanswerslist} \question Is Jane Doe alive? \begin{mcanswerslist} \answer a \answer b \answer c \answer d \answer[correct] e \answer f \end{mcanswerslist} \end{mcquestions} \end{document} Screenshot using output=answers:

  • Adjusting different column widths automatically in a table
    by Soluble on September 7, 2026 at 7:36 am

    I saw the adjustment of column width in a table in this link. When I implemented it, I observed that both columns are getting the same width, although it is not necessary in one column. For example, one \documentclass[a4paper,10pt]{article} \usepackage{tabularx} \begin{document} \begin{table} \begin{tabularx}{\columnwidth}{X|X}\hline Limit of sequence & A sequence said to have limit L if given any error e, all the terms of the sequence except finitely many have error at most the given number e.\\\hline \end{tabularx} \end{table} \end{document} I observed that in the output, I get two columns of the same width. But the first column has not many entries; it is the second column only, whose size needs to be adjusted automatically. How can I modify above table? Or is there any other way to adjust automatically the column widths?

  • How to adapt extent of \rvert with mathpazo?
    by user1362373 on September 7, 2026 at 7:15 am

    When I use inlined derivatives in Computer Modern, the extent of the vertical line matches that of the slash: \documentclass{standalone} \usepackage{amsmath} \begin{document} $du/dx\rvert_a$ \end{document} By contrast, when I use Mathpazo, the extents do not match: \documentclass{standalone} \usepackage{amsmath} \usepackage[sc,osf]{mathpazo} \usepackage[T1]{fontenc} \begin{document} $du/dx\rvert_a$ \end{document} The bottom of the vertical line is seen to be lower than the bottom of the slash. How can I adjust the vertical line to avoid this mismatch?

  • Immediate expanding of \clist_map for use with expand= in tblr environment
    by Don Hosek on September 7, 2026 at 1:07 am

    For maintainability in a tblr, I’ve developed a macro that works from lists to handle setting the entries. It works pretty well but with one exception: I would like to have it expand the following: \clist_map_inline:Nn \l_fd_clist { & csname pl_##1endcsname } for filling in the cells of a row (the various pl_WHATEVER macros are set earlier in the process). But apparently the expansion is only one level deep (which most of the time is good because otherwise the earlier list handling wouldn’t work correctly). I could split out the code that interprets the input lists and that sets the line and only have the latter part of the expand= option, which might be the best option (it would also allow me to deal with the awkwardness of the fact that I still have a manually generated header row which needs to be kept in sync with the body), but I don’t really like the idea of having to have two macros for each line instead of one like I have now. (Although as I think about it, it also occurs to me that I could do something like \edef\fdline#1#2#3#4{% \noexpand\setfdline{#1}{#2}{#3}{#4}% \clist_map_inline … } but I’d figured I’d see if there was something added in to the TeX core that I’m unfamiliar with or if in the course of writing out this question I’ve come across the best solution.

  • The `.bib` file does not work properly on the journal's submission platform
    by Hausdorff on September 6, 2026 at 6:40 pm

    The \cite{} command works correctly on my PC. However, on some journal platforms, citations appear as [?]. I uploaded the following .tex and .bib files to the journal's submission platform (Elsevier). .tex file \documentclass{article} \begin{document} \section{Introduction} This is an example citation of an article \cite{einstein}. \bibliographystyle{plain} \bibliography{references} \end{document} \endinput .bib file @article{einstein, author = {Albert Einstein}, title = {The Foundation of the General Theory of Relativity}, journal = {Annalen der Physik}, volume = {354}, number = {7}, pages = {769--822}, year = {1916} } OUTPUT on my PC OUTPUT on the journal's submission platform (Elsevier). Please let me know how to overcome this issue.

  • Redefining \chapter titleclass as "straight" removes all Chapter ToC Entries
    by BarbarianLunatic on September 6, 2026 at 1:42 pm

    I am currently setting up the structure for the Book-Project I am working on and ran into a problem. As a preliminary: I use a package called typewriter, which does not behave like normal fonts. It places an 'old style' dashed rule instead of a line, for instance. I use a 'Custom ToC Structure', which I wished to include into the MWE, for the sake of completeness... The Problem: I wanted to remove the space at the top of chapters, which appears for no apparent reason and is hard to get rid of, with the typewriter package in use [see Image 1]. So I started looking into \titleclass{\chapter}{straight}, which did give me the desired results for the chapter titlepage, but introduced another problem: --> The Chapter TOC entries are missing [See Image 2]. I do not wish to add too much code in the documents, but want to define the TOC chapter Entries the way they are without the \titleclass{\chapter}{straight}. However much I looked, I could not find anything about this issue. MWE: \documentclass[12pt,oneside]{book} % oneside only for MWE \usepackage[ paperwidth=148mm,%242mm, paperheight=85mm, top=17mm, bottom=10mm, inner=15mm, outer=13mm, ]{geometry} \usepackage{nopageno} \usepackage{lipsum} \usepackage[T1]{fontenc} \usepackage{textcomp} % Definitions for typewriter package (it gives my books an oldschool feel, % without having to buy an actual typewriter) \providecommand\ttgreyone{.18} \providecommand\ttgreytwo{.8} \providecommand\ttrotatebold{5} \providecommand\ttdownbold{20000} \providecommand\ttrightbold{35000} \providecommand\ttdownshifttwo{15300} \providecommand\ttrotatenormal{1.3} \providecommand\ttrightnormal{20000} \providecommand\ttdownnormal{20000} \usepackage{typewriter} \usepackage{scalefnt} % typewriter package does not support commands % like \LARGE or \fontsize, which is why I make use of \scalebox \usepackage[calcwidth]{titlesec} \usepackage{tocloft} \usepackage{titletoc} \usepackage{graphicx} \usepackage{fancyhdr} % For setting up the custom ToC \usepackage{array} % Header Definition with fancyhdr \pagestyle{fancy} %% \fancyhf{} \chead{→ \thepage{} ←} %Chapter formatting \titleclass{\chapter}{straight} % setting class to 'straight' removed the space and % the rule, but also the chapter entries from the TOC \titleformat{\chapter}[display] {} {\centering\cleardoublepage\mbox{}\vspace{.55cm}\scalebox{1.48}{Scroll \thechapter}} {1cm} {\centering\scalebox{1.73}} \titlespacing*{\chapter}{0pt}{1cm}{.1cm} % initial Chapter formatting [Image 1] %\titleformat{\chapter}[display] %{} %{\centering\scalebox{1.48}{Scroll \thechapter}} %{.5cm} %{\centering\scalebox{1.73}} % Custom ToC Structure \makeatletter \def\MBox#1#2#3#4{% \parbox[t]{0.68\linewidth}{#1}% \makebox[0.1\linewidth]{#2}% \makebox[0.05\linewidth][l]{#3}\\[#4]} \renewcommand*\l@part [2]{\MBox{% \scalebox{1.5}{#1}}{}{}{10pt}} \renewcommand*\l@chapter [2]{\hspace*{1.25cm}\MBox{#1}{% \raisebox{-3pt}{% \scalebox{2}{→}}}{\textpeso.#2}{5pt}} \renewcommand*\l@section [2]{\hspace*{1.25cm}\MBox{#1}{% \raisebox{-3pt}{% \scalebox{2}{→}}}{\textpeso.#2}{5pt}} \renewcommand{\numberline}[1]{Scroll #1:~\hfil} \makeatother %ToC Title \setlength{\cftbeforetoctitleskip}{1em} \renewcommand{\contentsname}{\hfil\scalebox{2}{The Tablets of Awakening}} \setlength{\cftaftertoctitleskip}{0em} \setlength\footskip{12pt} \begin{document} \pagenumbering{Roman} \addtocontents{toc}{\protect\thispagestyle{fancy}} %pagenumber on TOC-Page % this is to ensure hyphenation and justified text with the typewriter package \fontdimen2\font=0.4em \fontdimen3\font=0.2em \fontdimen4\font=0.1em \fontdimen7\font=0.1em \hyphenchar\font=`\- % Place TOC \tableofcontents % add part to TOC without pagenumbers \addtocontents{toc}{\cftpagenumbersoff{part}\mbox{}\\[9pt]} \addcontentsline{toc}{part}{\hspace{.5cm}Part 1: The 1st Part of this Work} \chapter{1st Chapter} \pagenumbering{arabic} \thispagestyle{fancy} \lipsum[12][2-5] % to highlight successful justification of text \chapter{2nd Chapter} \thispagestyle{fancy} \end{document} Any Help appreciated!

  • How do I use LaTeX to create unicode font handwriting grid templates?
    by mathrm alpha on September 6, 2026 at 12:12 pm

    I want to digitize my handwriting and convert it into a digital font file. Are there any LaTeX grid templates available for this? How can I create a grid with writing guidelines that automatically covers the Unicode range?

  • Are table rules untagged in a tagged PDF? Checkers disagree
    by fishface342 on September 6, 2026 at 12:17 am

    Trying to make a long document work well with tagging, I ran into an issue where two accessibility checkers disagree about whether table horizontal lines are tagged correctly. Specifically, for the following example, the current version of PAC (26.1.0.0) reports that the three \hline objects are not tagged, whereas Acrobat's accessibility checker seems fine with this. Same issue with booktabs using \toprule, etc. Not sure whether this is a bug, and if so, whether it's in one of the checkers or in the original pdf generation, but I figured people here will know better than me. Thanks in advance! MWE (compiling with pdfLaTeX): \DocumentMetadata{lang=en-US, pdfversion=1.7, tagging=on} \documentclass{article} \begin{document} \begin{tabular}{ll} \hline A & B\\ \hline C & D\\ \hline \end{tabular} \end{document}

  • Mimicking Automated Contents Chapter Entries by Using \addcontentsline{toc}{chapter}
    by Jethro on September 5, 2026 at 10:27 pm

    This question is motivated by the post: Customized chapter TOC entries with modified roman numeral displays MWE: \documentclass[12pt,openany]{book} \usepackage{titlesec,tocloft} \renewcommand{\thechapter}{\Roman{chapter}} \setlength{\cftchapnumwidth}{3em}% Width of chapter numbers in ToC \renewcommand{\cftchapaftersnum}{.} % Add a period after each chapter number in ToC \renewcommand{\cftchapleader}{\dotfill}% Leader between ToC entry and page number \titleformat {\chapter} % <command> [display] % <shape> {\LARGE\centering\bfseries} % <format> {CHAPTER \thechapter.} % <label> {25pt} % <sep> {} % <before-code> {} % <after-code> \begin{document} \tableofcontents \chapter{This is the First Chapter Heading} \addcontentsline{toc}{chapter}{\hskip 36pt This is the First Chapter Heading} \chapter{This is the Second Chapter Heading} \addcontentsline{toc}{chapter}{\hskip 36pt This is the Second Chapter Heading} \end{document} which produces the Table of Contents: I would like to mimic the chapter entries in the Table of Contents as automatically generated by the command \chapter as manually generated by the command \addcontentsline{toc}{chapter}{}. For example, the first chapter entry manually coded, I have, \addcontentsline{toc}{chapter}{\hskip 36pt This is the First Chapter Heading}. However, I need to somehow add an I., flushleft, without affecting \hskip 36pt starting from I. (Similarly, for the second entry.) This will align me to facilitate some old documents which I have previously added entries to the Table of Contents using \addcontentsline{toc}{chapter}{} previous being made aware of @Werner's excellent Table of Contents macro, somewhat recently. So, is it possible (and if so) how I may easily produce the formatted chapter entries by going the route of \addcontentsline{toc}{chapter}?

  • tabularray diagbox not working with xepersian
    by Shahriar on September 5, 2026 at 6:01 pm

    \documentclass{article} \usepackage{xepersian} \settextfont{IRXLotus} \usepackage{tabularray} \UseTblrLibrary{diagbox} \begin{document} \begin{tblr}{ colspec = {c c c}, hlines, vlines, } \diagbox{X}{Y} & A & B \\ 1 & 2 & 3 \\ \end{tblr} \end{document} Running this, I get Undefined control sequence. \end error. The culprit is xepersian + tabularray (if I remove xepersian it renders correctly). But what's the workaround? Versions: xepersian: 26.01.01 tabularray: 2025C diagbox: 2.4 biditools: (not installed) bidi: 26.01.08 Update \makeatletter \providecommand\UseMathForPositioningText{% \m@th } \makeatother Adding this between the two packages loading command makes it work, but the text is not aligned correctly... I don't know whether it's the expected alignment or not.

  • When a Chapter Title Can be Modified for a Table of Contents Entry? [duplicate]
    by Jethro on September 5, 2026 at 5:29 pm

    This extends the question related in Customized chapter TOC entries with modified roman numeral displays. MWE: \documentclass[12pt,openany]{book} \usepackage{titlesec,tocloft} \renewcommand{\thechapter}{\Roman{chapter}} \setlength{\cftchapnumwidth}{3em}% Width of chapter numbers in ToC \renewcommand{\cftchapaftersnum}{.} % Add a period after each chapter number in ToC \renewcommand{\cftchapleader}{\dotfill}% Leader between ToC entry and page number \titleformat {\chapter} % <command> [display] % <shape> {\LARGE\centering\bfseries} % <format> {CHAPTER \thechapter.} % <label> {25pt} % <sep> {} % <before-code> {} % <after-code> \begin{document} \tableofcontents \chapter{This is the First Chapter Heading} \chapter{This is the Second Chapter Heading but It is Longer Than the First So That It Extends Over Multiple Lines in the ToC} \end{document} The Table of Contents output: In this entry each chapter title is reported exactly in the Table of Contents. I would like to delineate, specifically, the second entry as "This is the Second Chapter Heading" instead of the much longer Chapter II. title. How may I modify chapter entries in the Table of Contents on as as-needed basis; in particular, for the second entry of this MWE?

  • tabto creates overlapping lines when using displaystyle maths
    by AO3 user without CSS knowledge on September 5, 2026 at 5:03 pm

    Using tabto on a line that contains displaystyle math causes the math expression to overlap with the text above it. Expected behavior at the top (what happens when I don't use tabto on the second line) VS what actually happens when I use tabto Here's a MWE : \documentclass{article} \usepackage{tabto} \begin{document} Text with a sum under it The sum :$\displaystyle\sum_{i=0}^{n}i$ Text that gets overlapped The sum :\tabto{\CurrentLineWidth} $\displaystyle\sum_{i=0}^{n}i$ \end{document} I'm doing calculations later on with the value tabto gives me, so I can't just get rid of it. Is there either another package that can give the current line width that isn't tabto and doesn't cause the same issues a way to force it to respect the actual line height Other people had similar issues with the package but the solutions proposed don't seem to work in that case. Edit: Here's what my actual document looks like. The tabto is here to calculate the max width of the following varwidth. \documentclass{article} \usepackage{tabto} \usepackage{varwidth, calc} \begin{document} Some text some text some text some text some text some text. Some more text on a new paragraph \tabto{\CurrentLineWidth}\begin{varwidth}[t]{\linewidth-\TabPrevPos} $\displaystyle\sum_{i=0}^{n}i$ Here is a longer paragraph that I want to be in a box. The tabto at the beginning helps me calculate the width of that box. \end{varwidth} \end{document}

  • How to reduce column separation space for particular column using tabularray
    by MadyYuvi on September 5, 2026 at 2:23 pm

    My code are: \documentclass[twocolumn]{article} \usepackage{amsmath} \usepackage{array} \usepackage{tabularray} \UseTblrLibrary{booktabs,siunitx} \usepackage{lipsum} \SetTblrInner{ rowsep=0pt, row{1}={l,b}, hborder{1}={belowspace=6pt}, hborder{2}={abovespace=2pt,belowspace=6pt}, hborder{Z}={abovespace=6pt}, width=\linewidth, row{1} = {guard}, } \begin{document} \begin{align} {F_d} = mgf\cos \theta + mg\sin \theta + \delta \tag*{(1)} \end{align} \lipsum[1] \begin{table} \caption{Value of Grid Convergence Index.\label{table1-09544062261479876}} \begin{tblr}{@{}X[1,l]lll@{}} \toprule {} & {\textit{Cpmin}} & {\textit{Cpmin}} & {\textit{Cpmin}}\\ \midrule {GCI N1-N2} & {0.95\%} & {0.46\%} & {0.86\%}\\ {GCI N2-N3} & {0.59\%} & {0.33\%} & {0.58\%}\\ \bottomrule \end{tblr} \end{table} \end{document} which produced the output as below: I need to reduce the column separation (equal space to all column) after first column, I understand that alignment X does the trick, if I applied to all column, but my requirement is all column should be aligned with l, please advise. Expected output: Else, kindly advise how to adjust (decrease) the columnsep after first column manually.

  • siunitx rounding to figures doesn't always pad trailing 0
    by Jakob on September 5, 2026 at 10:23 am

    I'm having trouble getting my desired figures padded when the number gets rounded. I don't want to use round-mode=places since I have differing amounts of leading 0s. Here's an example: \documentclass{article} \usepackage{siunitx} \sisetup{ round-mode = figures, round-precision = 3, round-pad = true } \begin{document} \num{0.7603} % 0.760: expected behaviour \num{0.9095} % 0.91: missing trailing 0 \end{document}

  • Improved alignment of molecules in a reaction suite
    by Nicolas on September 4, 2026 at 8:58 pm

    To show different possible mechanisms, I code this figure: \documentclass[border=3mm]{standalone} \usepackage{graphicx} % Required for inserting images \usepackage{chemfig} \usetikzlibrary{arrows,bending} % \tikzset {[foo /.tip = {Stealth[sep] Latex[sep]}} % \tikzset{ niv2/.tip = {Stealth[red, sep=5pt]_.} } % \tikzset{ niv1/.tip = {Stealth[red, sep=1pt]_.} } % \tikzset{ niv123/.tip = {Stealth[red, sep=1pt]_.} } \begin{document} \schemestart \chemfig{C(-[:120]H)(-[:240]H_3C)=[@{p1}]C(-[:60]H)(-[:300]H)} \+ \chemfig{@{p2}H-[@{p3}]@{p4}\charge{0=\|,90=\|,270=\|}{Cl}} \hspace{.3cm} \arrow(b--)[,1.3,,,draw=none] \subscheme{ \chemfig{CH_3-CH_2-\charge{90:4pt=$\oplus$}{CH_2}} \arrow(c--d){->}[-90,1.5,,,,draw=none] \chemfig[baseline=15pt]{CH_3-\charge{110:3pt=$\oplus$}{CH}-CH_3} } \subscheme{ \arrow(@c--e){->[\charge{0=\|,90=\|,180=\|,-90=\|,45:4pt=$\ominus$}{Br}]}[,1] \chemfig{CH_3-CH_2-CH_2-Br} \arrow(e--f){->}[-90,1.5,,,,draw=none] \chemfig{CH_3-CH(-[:-90]Br)-CH_3} \arrow(@d--@f){->[\charge{0=\|,90=\|,180=\|,-90=\|,45:4pt=$\ominus$}{Br}]}[,1] } \chemmove{ \draw[thick,shorten >=10pt] (b.east) -- ++(1,0) |- (c.west); \draw[thick,shorten >=10pt] (b.east) -- ++(1,0) |- (d.west); \draw[shorten <=1pt,shorten >=1pt](p1).. controls +(80:20mm) and +(100:10mm)..(p2); \draw[shorten <=1pt,shorten >=4pt](p3).. controls +(80:6mm) and +(100:6mm)..(p4); } \schemestop \end{document} Problem: the molecules are not well aligned which means that the arrows (especially the bottom for the bromide ion) are tilted. How can I align vertically?

  • Customized chapter TOC entries with modified roman numeral displays
    by Jethro on September 4, 2026 at 5:06 pm

    MWE: \documentclass[12pt,openany]{book} \usepackage{titlesec,tocloft} \renewcommand{\thechapter}{\Roman{chapter}} \renewcommand{\cftchapaftersnum}{.} % Add a period after each chapter number in the TOC. \usepackage{titlesec} \titleformat{\chapter}[display]{\Huge\centering\bfseries}{CHAPTER \thechapter.}{25pt}{}{} \makeatletter \def\l@chapter#1#2{% \pagebreak[3] \bfseries \vskip .75em plus 1pt \@tempdima 3em \begingroup \parindent \z@ \rightskip \@pnumwidth \parfillskip -\@pnumwidth \advance\leftskip\@tempdima \hskip -\leftskip \leavevmode %\MakeUppercase {#1} \dotfill \hbox to\@pnumwidth{\hss #2} \par \endgroup } \makeatother \begin{document} \tableofcontents \chapter{This is the First Chapter Heading} \chapter{This is the Second Chapter Heading but It is Longer Than the First So That It Extends Over Multiple Lines in the TOC} \end{document} The output: I am trying to add a period after each roman numeral chapter entry. I figured that \renewcommand{\cftchapaftersnum}{.} should do the trick. It doesn't. How may I add a period after each roman numeral in the TOC?

  • newline in caption of tabularray
    by albert on September 4, 2026 at 4:22 pm

    A bit a similar question to Create a hyper link in caption of tabularray with a different "payload": \begin{DoxyTable}{1}{PRE~\newline POST}{}{0} Some longer text for better visibility\\ \end{DoxyTable} As can be seen in the output there is no newline there: Unfortunately the solution of Create a hyper link in caption of tabularray (using \protect) does not work here. Where DoxyTable is the wrapper as used and shown in the following (and a bit large) MWE: \documentclass[twoside]{book} \usepackage[pdftex,pagebackref=true]{hyperref} \usepackage{tabularray} \usepackage{longtable} \UseTblrLibrary{varwidth} \ExplSyntaxOn \dim_new:N \doxytablewidth \NewDocumentCommand \doxycalculatetablewidth {} { \cs_set_protected:Nn \__tblr_build_whole: { \__tblr_get_table_width: \dim_gset:Nn \doxytablewidth { \tablewidth } } } \ExplSyntaxOff % define a theme for the DoxyTable environment (without caption) \NewTblrTheme{DoxyTableBareTheme}{ \DefTblrTemplate{firsthead}{default}{}% \DefTblrTemplate{middlehead, lasthead}{default}{}% \DefTblrTemplate{contfoot-text}{default}{}% } % define a theme for the DoxyTable environment (with caption) \NewTblrTheme{DoxyTableCaptionTheme}{ \SetTblrStyle{firsthead}{font=\bfseries}{}% \DefTblrTemplate{middlehead, lasthead}{default}{}% \DefTblrTemplate{contfoot-text}{default}{}% } % Define a table environment to use with Doxygen % parameters: % - #1: number of columns % - #2: table caption (can be empty) % - #3: label to refer to the table (can be empty) % - #4: 1=table has a heading row, 0=no heading row % - #5: body of the table (part between start{DoxyTable}..\end{DoxyTable} \NewDocumentEnvironment{DoxyTable}{m +m m m +b}{% \par% \def\hascaption{#2}% \def\haslabel{#3}% \ifx\hascaption\empty% if caption is empty \SetTblrOuter[longtblr]{theme=DoxyTableBareTheme,entry=none}% table without caption or label \else% caption not empty \ifx\haslabel\empty% if label is empty \SetTblrOuter[longtblr]{theme=DoxyTableCaptionTheme,caption={#2}}% set table caption \else% label not empty \SetTblrOuter[longtblr]{theme=DoxyTableCaptionTheme,caption={#2},label={#3}}% set table caption and label \fi% \fi% \begingroup \doxycalculatetablewidth \sbox0{% first render the table in a savebox to calculate the width of the table which will be stored in \doxytablewidth \begin{tblr}{hlines,vlines,measure=vbox,colspec={*{#1}{l}}}% #5 \end{tblr}% }% end of sbox0 \endgroup \ifdim\doxytablewidth>\linewidth% use flexible columns % now render the table for real \begin{longtblr}{hlines,vlines,% automatically set horizontal and vertical cell lines measure=vbox,% needed to allow nested lists and tables colspec={*{#1}{X[-1]}},% set column type for all columns rowhead=#4} % set which row is the header (0=disable, 1=enable) #5 \end{longtblr}% \else% use fixed left aligned columns % now render the table for real \begin{longtblr}{hlines,vlines,% automatically set horizontal and vertical cell lines measure=vbox,% needed to allow nested lists and tables colspec={*{#1}{l}},% set column type for all columns rowhead=#4} % set which row is the header (0=disable, 1=enable) #5 \end{longtblr}% \fi% }{% no end marker needed anymore }% \usepackage{caption} \captionsetup{labelsep=space,justification=centering,font={bf},singlelinecheck=off,skip=4pt,position=top} \begin{document} Test \hypertarget{index_bbb}{} \begin{DoxyTable}{1}{PRE~\newline POST}{}{0} Some longer text for better visibility\\ \end{DoxyTable} \end{document} How to solve this problem?

  • Problem of vertical placement of two molecules
    by Nicolas on September 4, 2026 at 12:57 pm

    I have the following chemical equation in Chemfigs: \documentclass[border=1mm]{standalone} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[french]{babel} \usepackage{chemfig} \usepackage{chemmacros} \begin{document} \setchemfig{scheme debug=true} \schemestart \chemfig{*6(--=---)} \arrow{->[\ch{Br2}]} \chemname{\chemfig{*6(--(<Br)-(<:Br)---)}}{trans-1,2-dibromo\\cyclohexane} \schemestop \end{document} The problem is that vertical alignment is not correct between cyclohexene and dibromocyclohexane. I tried the trick to add\arrow{0}[,0] but it does not work. How to properly replace cycles vertically like this ?

  • How to change the spacing between the title, the text, and the equation itself?
    by Alastair Stratford on September 4, 2026 at 9:04 am

    The spacing between the title and text, and the text itself and equation is bit too much for me. The equation on the middle is also small. This is what I've come up so far. \documentclass[12pt,english]{article} \usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry} \usepackage{blindtext} \title{Formal Definition of Limits\\ (Epsilon-Delta Definition)} \date{} \begin{document} \maketitle A simpler way to understand limits is when a certain function $f(x)$ approaches a certain value $a$, but not exactly to it, thus it has a limit $L$. Or we can write it like this: \[ \lim_{x \to a } f(x) = L \] \end{document} And this is the result so far:

  • batch generate letters with variable content
    by underflow on September 3, 2026 at 10:45 pm

    I need to generate a batch of reports. Each report gives the pass/fail results of a series of labs, with data taken from a text file. Here is a minimal (almost) working example: \documentclass{letter} \begin{document} \newcommand{\lab}[7]{ \begin{letter}{} \signature{Lab director} \opening{Dear #1,} Here are the result of your lab report: \begin{tabular}{ll} {#2}: & {#3} \\ {#4}: & {#5} \\ {#6}: & {#7} \end{tabular} \closing{Sincerely yours,} \pagebreak \end{letter}} \input{mwe_list.tex} \end{document} and here's the data file ("mwe_list.tex"): % Format of the data file: % % \lab{the name of the place} % {name of lab #1} % {pass/fail} % {name of lab #2} % {pass/fail} % {name of lab #3} % {pass/fail} % % NOTE: The number of labs is fixed, but the labs for different people could be % different, and some people attempted fewer than three labs \lab{Alice} {heat fusion} {pass} {energy content} {pass} {acid dissociation} {pass} \lab{Bob} {energy content} {pass} {} {} {} {} As this example shows, some reports have fewer than 3 items. Question: How should I modify the tex code so it only prints the name of lab + results that's carried out? I have in mind something like "if {#3} is not {} then print {#3:}: {#4}", but I don't know how to do that in latex, and I don't know how to combine that with e.g. tabular. I do realize that my MWE is hacky, so I welcome suggestions on how to do this properly. Thanks!

  • why adding a label at the end of the document is not found?
    by R. N on September 3, 2026 at 9:12 pm

    In order to be compliant with a template given by my company, I need to have a main part and optionally an appendix. My problem is that the foot of the main part should contain the total number of pages only for the main part while the appendix's foot should restart the counter. Therefore, I thought about lastpage package. But this one is not accepting that I put 'its' label somewhere else (when I start the appendix), because it redefines the label anyway. So I thought that I could mimic lastpage by adding a label at the end of the document if this label has not been defined. This works correctly if I add my label in the middle of the document, but not if the label is not detected at the end of the document. (So, okay I could do everything manually but since the final purpose is to share this template with co-workers, they will make mistakes for sure and complain) Here is a MWE: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{lastpage} % or another \usepackage{fancyhdr} \pagestyle{fancy} \fancyfoot[C]{\thepage{}/\pageref{LastMainPage}} \makeatletter \AddToHook{enddocument}{% or enddocument/afterlastpage \@ifundefined{r@LastMainPage}{% add \label{LastMainPage}% }{def}% } \makeatother \begin{document} page 1/2 \newpage page 2/2 % % appendix are optional so commented for this test % \newpage % \appendix % \label{LastMainPage} % then I will add it to \appendix % \pagenumbering{roman} % \fancyfoot[C]{\thepage{}} % appendix i % \label{LastMainPage} % if I uncomment this is working \end{document} In this example, despite the fact that I can see add on the produced pdf (indicating that the if condition works correctly in the hook at the end of the document), I get the warning: Reference 'LastMainPage' on page 2 undefined on input line 29 and very logically I have 2/?? on the produced foot. EDIT: to be more precise, I just realized that this unwanted behaviour appears when I use latexmk as I will be done on Overleaf. While if I run pdflatex or lualatex twice, on the first compilation the reference is not found while on the second it is as expected. latexmk version: 9 March 2026. Version 4.88 pdfTeX version: 3.141592653-2.6-1.40.29 (TeX Live 2026) luaTeX Version: 1.24.0 (TeX Live 2026) So do you see a simple way to solve this ? Is there a way to add a label at the end of a document without getting the warning/error: Reference 'LastMainPage' on page 2 undefined on input line 29 ? Or is there a way to redirect a label to another (here LastMainPage would point toward LastPage) if it has not been found ?

  • How do you change the math font in ltx-talk?
    by David Purton on September 3, 2026 at 1:33 pm

    When I try to change the math font in ltx-talk it is only partly successful. Operators remain in the original New CM Sans Math font. What's going on and how to fix? \DocumentMetadata{} \documentclass{ltx-talk} \setmathfont{STIX Two Math} \begin{document} $x=\sin y$ \end{document}

  • Unicode-math based solution with bold math binary symbols? [duplicate]
    by Explorer on September 3, 2026 at 2:52 am

    The post comes from this classical one, but the unicode-math version, I want to bold some math binary symbols: \documentclass{article} \usepackage{bm} \begin{document} $a + b$ vs $a \bm{+} b$ $a - b$ vs $a \bm{-} b$ $a \times b$ vs $a \bm{\times} b$ $a \div b$ vs $a \bm{\div} b$ \end{document} However, as we all known, unicode-math was conflict with bm package, what I want was as below: The code with unicode-math.... \documentclass{article} \usepackage{unicode-math} \setmathfont{latinmodern-math.otf} \setmathfont[range={`+,\minus,\times,\div}]{STIX Two Math}% ? \begin{document} $a + b$ % vs $a + b$ $a - b$ ? % vs $a - b$ % ? $a \minus b$ % vs $a \minus b$ % ? $a \times b$ % vs $a \times b$ $a \div b$ % vs $a \div b$ \end{document} I found no solution with unicode-math (I only found that STIX Two Math's symbols are thicker, but not in matched style), any suggestions? Notes that other code in the reference link was not the same bahavior of \bm, I want a more Latin Modern Math-like style (it means the tip of + is rounded, but not butt, for example) here...

  • How to draw/visualize/simulate to show the diffence between the two almost identical curves?
    by Black Mild on September 1, 2026 at 9:45 am

    This question is related to an interesting question on mathSE. The blue curve $E$ is the ellipse $\left(\frac{4x}{\pi}\right)^2+\left(\frac{y}{\ln\left(\sqrt2+1\right)}\right)^2=1$ and the red curve $L$ is $y^2=\ln^2\left(\sqrt2\cos x-\sqrt{\cos(2x)}\right)$ are almost identical in shapes. So far several answers show that they are different (some 1/10000) but almost identical (it's still open for that exact value/measure of how different they are). Naturally we want to see the difference. The question is to draw/visualize/simulate how different they are. It's interesting in mathematics but challenging in drawing due to very small diffrences. I can draw them (the code below is a MWE); the below left is E over thicker L, the below right is L over a thicker E; however we can not see the difference. Any tools (tikz, pgfplot, asymptote, luadraw, julia, ...) are allowed (standalone can be integrated into LaTeX/beamer). I just think of f(x)-g(x), f(x)/g(x), ... then scale by 10000 in graph, but not yet clear and complete. Please explain some maths behind your way, if any. // https://asymptote.ualberta.ca/ // https://math.stackexchange.com/questions/5147646/why-is-this-curve-almost-an-ellipse-y2-ln2-left-sqrt2-cos-x-sqrt-cos2x/5148177 // The blue curve $E$ is the ellipse $\left(\frac{4x}{\pi}\right)^2+\left(\frac{y}{\ln\left(\sqrt2+1\right)}\right)^2=1$. import graph; usepackage("amsmath"); size(12cm); real a = pi/4; // \approx 0.7854 real b = log(sqrt(2)+1); // = arcsinh(1) \approx 0.8814 write(a); write(b); // The ellipse E real xE(real t) { return a*cos(t); } real yE(real t) { return b*sin(t); } // The curve L real yL_upper(real x) { // Tránh sai số dấu phẩy động lân cận nghiệm bằng hàm max real u = sqrt(max(cos(2*x), 0)); return log(u + sqrt(u^2 + 1)); } real yL_lower(real x) { return -yL_upper(x); } // draw on a picture with pen void draw_curve_E(picture pic=currentpicture, pen p) { draw(pic, graph(xE, yE, 0, 2*pi), p); } void draw_curve_L(picture pic=currentpicture, pen p) { path upper = graph(yL_upper, -a, a, operator ..); path lower = reverse(graph(yL_lower, -a, a, operator ..)); draw(pic, upper -- lower -- cycle, p); } pen penE = blue+1pt; pen penL = red+1pt; pen draw_first = opacity(.3) + 4pt; picture picaxes, picE, picL, picEL, picLE; real extra = .1; xaxis(picaxes, -a-extra, a+extra, gray); yaxis(picaxes, -b-extra, b+extra, gray); add(picE,picaxes); add(picL,picaxes); add(picEL,picaxes); add(picLE,picaxes); draw_curve_E(picE, penE); string sE=" \begin{minipage}[C]{6cm} \[ \left(\frac{4x}{\pi}\right)^2+ \left(\frac{y}{\ln(\sqrt2+1)}\right)^2=1 \] \begin{align*} a&=\pi/4 \approx 0.7854\\ b&=\ln(\sqrt2+1)\\ &=\operatorname{arsinh}(1)\approx0.8814 \end{align*} \[ \frac{x^2}{a^2}+\frac{y^2}{b^2}=1 \] \end{minipage}"; label(picE,Label(scale(.6)*sE,penE),(-a-extra,0),W); draw_curve_L(picL, penL); string sL=" \begin{minipage}[C]{6cm} $$y^2=\ln^2\left(\sqrt2\cos x-\sqrt{\cos(2x)}\right)$$ $$2\sin^2x +\sinh^2 y=1$$ \end{minipage}"; label(picL,Label(scale(.6)*sL,penL),(a+extra,0),E); draw_curve_E(picEL, penE + draw_first); draw_curve_L(picEL, penL); draw_curve_L(picLE, penL + draw_first); draw_curve_E(picLE, penE); real dx=1, dy=1.8; add(shift(-dx,0)*picE); add(shift(dx,0)*picL); add(shift(-dx,-2dy)*picEL); add(shift(dx,-2dy)*picLE); label("They are different but almost identical!",(0,-dy-.2)); label("How do we see their difference ?",(0,-2dy-b-.8)); //shipout(bbox(2mm,invisible)); shipout(bbox(2mm,Fill(.2yellow+.8white)));

  • How to draw realistic, semi-3D chemistry glassware (volumetric flask) in pure TikZ?
    by user446526 on September 1, 2026 at 8:34 am

    I am trying to recreate an educational chemistry diagram illustrating the dilution of a solution using pure TikZ. Here is the target image I want to emulate (specifically the realistic, glossy 3D look of the glassware and liquid): I have made an initial attempt at drawing the volumetric flask and adding some basic gradients to simulate a 3D effect and control the water level. Here is my current Minimal Working Example (MWE), which is stripped of all custom fonts and language packages, along with a screenshot of my current output: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[x=1cm, y=1cm] % Water level control \def\waterlevel{-0.5} % Main flask path \def\flaskpath{ (0,-2.115) .. controls (1.85,-2.0) and (0.2,-0.45) .. (0.225,-0.01) .. controls (0.15,1.95) and (0.25,1.55) .. (0.25,1.725) .. controls (0.175,2.15) and (0.3,2.15) .. (0.3,2.225) .. controls (0.2,2.35) and (-0.2,2.35) .. (-0.3,2.225) .. controls (-0.3,2.15) and (-0.175,2.15) .. (-0.25,1.725) .. controls (-0.25,1.55) and (-0.15,1.95) .. (-0.225,-0.01) .. controls (-0.2,-0.45) and (-1.85,-2.0) .. cycle } % 1. Flask glass (3D transparent background) \fill[left color=gray!10, right color=gray!30, middle color=white, opacity=0.4] \flaskpath; % 2. Liquid with 3D gradient \begin{scope} \clip \flaskpath; \fill[left color=blue!60!black, right color=blue!40, middle color=blue!15, opacity=0.85] (-2,-2.2) rectangle (2, \waterlevel); % Liquid surface line \draw[blue!80!black, thick, opacity=0.6] (-1, \waterlevel) -- (1, \waterlevel); \end{scope} % 3. Flask outline \draw[line width=1.3pt, color=black!75] \flaskpath; % 4. Top stopper/neck details \draw[line width=1.3pt, color=black!75] (-0.3,2.225) .. controls (-0.15,2.125) and (0.15,2.125) .. (0.3,2.225); \draw[line width=1.3pt, color=black!75] (-0.25,2.275) .. controls (-0.15,2.2) and (0.15,2.2) .. (0.25,2.275); \draw[line width=1.3pt, color=black!75, left color=gray!5, right color=gray!40, middle color=white] (0.25,2.275) .. controls (0.15,2.325) and (0.15,2.375) .. (0.175,2.425) .. controls (0.45,2.5) and (0.3,2.7) .. (0,2.675) .. controls (-0.3,2.7) and (-0.45,2.5) .. (-0.175,2.425) .. controls (-0.15,2.375) and (-0.15,2.325) .. (-0.25,2.275) .. controls (-0.1,2.325) and (0.1,2.325) .. (0.25,2.275); \draw[line width=1.3pt, color=black!75] (-0.25,2.625) .. controls (-0.15,2.575) and (0.15,2.575) .. (0.25,2.625); % 5. Calibration mark (red ring on the neck) \draw[line width=1pt, red!70!black] (-0.23, 1.2) .. controls (-0.1, 1.15) and (0.1, 1.15) .. (0.23, 1.2); \end{tikzpicture} \end{document} My question: How can I further improve the shading, highlights, and transparency of this TikZ code to closely match the professional, glossy 3D rendering seen in the target image? (Note: I am looking for a pure TikZ solution and prefer not to use pst-labo or external 3D software if possible).