Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [patching]

{patching} is for questions about patching the definition of macros.

Filter by
Sorted by
Tagged with
0 votes
0 answers
77 views

Patching \cref and \Cref to write additional information to the .aux file

I need to patch the macros \cref and \Cref so that when used like this: \cref{label1,label2,label3} besides generating the normal layout in the document, they write something like this to the .aux (...
Gabriele's user avatar
  • 1,943
6 votes
2 answers
175 views

Command to renew other commands

Is it possible to create a command which takes the name of a command c as an argument and redefines c (e.g. via renewcommand) in terms of itself but adds some new functionality? In short, can we ...
PaulProgrammerNoob's user avatar
0 votes
1 answer
37 views

How to patch the \totalpoints command correctly without error on first compilation

My goal is to have half points that are printed with a comma as a decimal symbol (e.g. 2,5 points). Thus, I use a workaround and multiply all points with 10 and use the patchmd command from etoolbox ...
imkrs_lbrun's user avatar
3 votes
2 answers
153 views

How to use `patchcmd` with a code containing `{`?

I have a macro with a long hbox, and I'd like to integrate a simple tikz box by adding a line of code in front of its {. However, I'm facing challenges due to the inclusion of curly braces in that ...
javadr's user avatar
  • 2,414
0 votes
1 answer
30 views

Adjust font size with \patchcmd{\normalsize} not working with TL 2022

I used to slightly adjust my font size with \patchcmd{\normalsize}. Consider this code: \documentclass[11pt]{memoir} \usepackage{etoolbox,lipsum} \makeatletter \patchcmd{\normalsize}{\@xipt}{{30pt}}{}...
Iacobus1983's user avatar
2 votes
1 answer
52 views

Overfull hbox in patched use of algorithm2e environment

I am using the algorithms environment from algorithm2e in a modified way with reduced width (following the solution here), see the MWE below. This generates an overfull box that I'd like to get rid of....
user279611's user avatar
0 votes
1 answer
19 views

Different linebreaks for chapter title on the chapter title page and in the Notes subheading (memoir)

I would like to specify my own line breaks for a chapter title in three places: on the chapter title page (ie first page of the chapter), in the corresponding subheading in the Notes chapter (ie for \...
tsj's user avatar
  • 580
0 votes
2 answers
71 views

Which way to alter commands is more robust/sustainable

I have a general question. If I'm writing a .cls file (or a package file, as well), what's the best way to edit standard commands like \section which are defined by the used standard class or latex....
lukeflo's user avatar
  • 1,597
0 votes
1 answer
40 views

How to transport code, not material, with a float?

My MWE: \documentclass[twoside]{book}% \usepackage{graphicx}% \usepackage{tikzducks}% \usepackage{lipsum}% \usepackage{color}% \begin{document} \color{red} \begin{figure} \...
ThorstenL's user avatar
  • 161
1 vote
0 answers
260 views

Collect information to render later

I am not sure I am using the right terms for describing what I want to do, so the title may be off. I want to be able to use a custom command like for example \PersonalData{Name}{Some Name} but not ...
Zelphir Kaltstahl's user avatar
0 votes
1 answer
46 views

How to patch samepage for svmono?

Continuing Why doesn't \samepage set \predisplaypenalty (to \@M or any other value)? , let's say we wish to patch LaTeX's \DeclareRobustCommand\samepage{\interlinepenalty\@M \postdisplaypenalty\...
user avatar
0 votes
1 answer
73 views

How make, that every page with section start have an empty style

There is some problem, that I can't understand. I want, that each page with start section has empty style \appto\section{\thispagestyle{empty}} I get an error ! Argument of \thispagestyle has an ...
Igor Yukhimenko's user avatar
0 votes
2 answers
59 views

Contents of sidewaysfigure env is out of page with TRT pagedir

With this example (lualatex with TRT pagedir) the image does not appear. how to solve the issue? \documentclass{article} \usepackage{graphicx} \usepackage[demo]{rotating} \pagedir TRT \bodydir TRT \...
Salim Bou's user avatar
  • 17.1k
1 vote
0 answers
37 views

A hook to add support for thmtool's notefont in ntheorem

I want to use ntheorem extended with thmtools. In the documentation of the latter, I read: notefont (Value: TEX code). Executed just before the note in the head is typeset, inside a group. Intended ...
sparusaurata's user avatar
1 vote
1 answer
59 views

How to replace the second match of a string of token using \patchcmd?

I will first raise a general question and then try to describe what I actually want to achieve. General question: How to patch the match other than the first one using \patchcmd The logic of the ...
Qi Tianluo's user avatar
0 votes
1 answer
59 views

Patch no longer finding search pattern for hyperref command despite previously working, unsure how to update it

Some time ago I used user Werner's solution provided here: https://tex.stackexchange.com/a/582389 in one of my own documents. Specifically, the goal was to make the part number and the part title in ...
tex_user_'s user avatar
1 vote
1 answer
81 views

Reliable way to patch a chapter in scrreport and article

I need to run a command after each chapter, so I need to patch chapters. If I do: \documentclass{scrreport} %% Works with memoir but not with scrreport \NewDocumentCommand\MyAddLabel{}{\label{mylabel}...
tobiasBora's user avatar
  • 8,804
0 votes
0 answers
45 views

Patching a math command using regexpatch

I want to allow my inline math to break lines after \sim, which I'm using a lot. To this end, I've tried: \usepackage{regexpatch} ... \xapptocmd{\sim}{\allowbreak}{SUCCESS}{FAIL} ... $X \sim N(0, 1)$ ...
Migwell's user avatar
  • 143
0 votes
1 answer
75 views

Changing the Default Vertical Page Position for a group of New Chapters with Patchcmd Command

I am using the patchcmd command in the preamble to specify a vertical position default for where new (unnumbered) chapters should begin on the page: \makeatletter \patchcmd{\@makeschapterhead}{\vspace*...
DDS's user avatar
  • 8,986
0 votes
0 answers
45 views

hyperref and \addcontentsline's patch in expl3 block

I want to patch \addcontentsline command for changing \thepage to \thechapter--\thepage. However I found that things went wrong when I used expl block: \documentclass{book} \usepackage{etoolbox} % \...
Syvshc's user avatar
  • 1,348
1 vote
1 answer
115 views

How can I patch `minted` to use `soul`s higlighting

I'd like to highlight code with a gray background like StackExchange does. I know that I can set bgcolor in minted to put a solid background color on inline code. However, this makes minted use ...
Eric's user avatar
  • 683
0 votes
1 answer
74 views

How to execute certain code at the beginning of every theorem?

I would like to inject certain code at the beginning of the environment theorem, defined with amsthm's \newtheorem. In my case, the code I wish to add is {\itemize\item[]\null\enditemize}\smallskip, ...
Jinwen's user avatar
  • 8,568
6 votes
4 answers
318 views

Wrapping a command (parametrically) - csname woes

I would like to "wrap" an existing command with another command. For example, suppose that there is one command \cmda I would like that each time this is called we end up executing: \...
Andrea Censi's user avatar
2 votes
1 answer
67 views

Automate row color overlays in tabular beamer

The following code in the MWE below makes the last (current) row shown on the respective slide overlayed in green: \begin{tabular}{cc} \cellcolor<+>{green} A & B \\ \cellcolor<+...
Vitus Schäfftlein's user avatar
1 vote
1 answer
35 views

Why doesn't this \xpathcmd work inside expl3 scope?

Consider the following example, the same \xpatchcmd works outside ExplSyntax, but doesn't work inside. Why is this happening? \documentclass{article} \usepackage{regexpatch} \begin{document} \def\...
Jinwen's user avatar
  • 8,568
4 votes
1 answer
128 views

How to use \csname inside \xpatchcmd?

Consider the following example, what is the correct way to use \csname and \endcsname inside \xpatchcmd? \documentclass{article} \usepackage{regexpatch} \begin{document} \def\foo{foo} \def\bar{with ...
Jinwen's user avatar
  • 8,568
1 vote
1 answer
43 views

How to patch a macro with options inside another macro with options?

In order to place the hyperlinks at the right place, I would like to patch a few format macros produced by cleveref. For example, \cref@theorem@format is defined as: macro:#1#2#3->#2\cref@theorem@...
Jinwen's user avatar
  • 8,568
1 vote
1 answer
172 views

Patch section command fails

I'd like to patch the section command to add at the end a simple \label in a way that is as generic as possible (I don't want to assume the number of arguments of the section command for instance, so ...
tobiasBora's user avatar
  • 8,804
4 votes
1 answer
4k views

\usetagform incompatible with microtype?

It seems that \usetagform in mathtools package is incompatible with microtype package as can be seen in the following MWE: \documentclass[10pt]{article} \usepackage{microtype} \usepackage{mathtools} \...
user182849's user avatar
1 vote
0 answers
31 views

Auto detect blank page and add something [duplicate]

i have a beamer \documentclass{beamer} \usepackage{xpatch} \makeatletter %\patchcmd\what{}{}{}{} ? \makeatother \begin{document} \frame{\frametitle{First} Something. } \frame{\frametitle{Second} ...
Zeno Shuai's user avatar
5 votes
2 answers
174 views

bidi package fail with recent version of multicol

I have this simple example of multicol in RTL document with bidi package. Version of multicol package in my TL2021 is 1.9b result after compilation with xelatex is incorrect \documentclass{article} \...
Salim Bou's user avatar
  • 17.1k
0 votes
1 answer
74 views

Remove extra space around single-spaced equations within a double-spaced document

I would like to use single-spaced equations with equation numbers in a double-spaced document. I found a solution to this problem: Single-spaced equations in double-spaced documents, but this solution ...
TobiR's user avatar
  • 594
2 votes
1 answer
166 views

Patch command by adding new (optional) arguments (and turn `newcommand` into `NewDocumentCommand`)

In a package, I'd like to customize an existing macro by adding an optional argument to control the size of an image. However, I've no idea how to patch a command to add arguments. Ideally I'd love to ...
tobiasBora's user avatar
  • 8,804
1 vote
1 answer
57 views

Patching \captionof fails

I would like to execute this or that command depending on whether \captionof is used for a figure or a table. So I patch \captionof with etoolbox to see if the float type parameter is of type table or ...
B Legrand's user avatar
  • 413
0 votes
1 answer
87 views

Unable to patch "\caption" if the package caption is loaded

I was inspired by this question to make the chapter names appear in the list of figures. This solution works very well if the caption package is not loaded. However, if this one (or subcaption) is ...
B Legrand's user avatar
  • 413
1 vote
3 answers
261 views

How does one keep a constant indentation for multiline items in tablenotes of a threeparttable?

Here an illustrative MWE: \documentclass[fontsize=11pt]{article} \usepackage{blindtext} \usepackage[flushleft]{threeparttable} \usepackage{booktabs} \begin{document} \blindtext \begin{table} \...
Euclides's user avatar
3 votes
2 answers
260 views

Patching \usepackage / \RequirePackage

I want to implement automatic benchmarking for the packages I load (some of which are my own). Right now my preamble takes 15 seconds to load, much longer than the rest of my document seems to take to ...
r0uv3n's user avatar
  • 33
1 vote
1 answer
44 views

After \patchcmd \thispagestyle{empty} sets the word "plain" in upper left corner on parts page in scrbook

I'd like to have a background image on every parts page in scrbook. Found this solution: How can I give each chapter page its own background image in scrbook? by @crf The linked solution would set ...
schmendrich's user avatar
  • 3,908
3 votes
3 answers
455 views

Keeping default optional argument when adding to command

TeX FAQ's "Patching existing commands" gives a method to add to existing commands that have an optional argument: \documentclass{article} \usepackage{letltxmacro} \newcommand{\rough}[2][\...
Luiz Martins's user avatar
7 votes
0 answers
273 views

Redefining Commands: Safety and Best Practices

There's plenty of questions on this site about redefining specific commands, but I couldn't find a more general, comprehensive question about the safety and best practices of redefining commands in ...
steve's user avatar
  • 2,174
0 votes
0 answers
94 views

patchcmd with if condtion

I've had the problem, that I needed a prefix in my list of figures/tables, but fortunately I found this solution. I work with the fancyhdr package, so I need the tocloft package with the title option....
flowmymind's user avatar
0 votes
0 answers
60 views

Is there a convenient hook to patch all of the AMS display math environments?

If I want to patch all of the amsmath display math environments to be wrapped in another environment (like for equation in this answer to adjust the line width), is there a convenient way to patch all ...
schtandard's user avatar
1 vote
1 answer
393 views

How to use a different fontfamily for italic text

I want my document to change from CMR to Garamond when using italic typeface, and automatically go back when not using italic. Preferably would this happen when I just issue the \textit{} command. Is ...
E. l4d3's user avatar
  • 707
2 votes
1 answer
229 views

Exercise package : use a non-indented list environment for

I use the exercise package for typesetting exercises and questions. I would like to avoid the classical indentation of the questions (due to the using of a list environment, but I'm not able to set ...
jowe_19's user avatar
  • 939
5 votes
2 answers
1k views

Problem with patching babel package

I am trying to use babel and biblatex package together but I am getting following error: ! Package biblatex Error: Patching 'babel' package failed. This is my code example: \documentclass[12pt,...
Lukáš Maliar's user avatar
3 votes
1 answer
583 views

Definitive way to pre- and append code, or patch commands?

Consider the following example: we have a command \mycmd, defined in some pacakge as: \DeclareRobustCommand{\mycmd}{% <original source code> } we want to patch this command, in the sense ...
Hyperplane's user avatar
0 votes
0 answers
112 views

diagbox with babel RTL tabular issue

I have issue with \diagbox in RTL tabular (babel with bidi=basic, lualatex engine), with xelatex bidi package provide patch of diagbox commands for right to left tabular, but for lualatex there isn't. ...
Salim Bou's user avatar
  • 17.1k
3 votes
1 answer
145 views

Editing a word in a sty file

I want to edit a word in a .sty file. I'm learning Latex and I don't know if it can be edited by using \makeatletter and \makeatother commands in the preamble. The .sty file (novel-PostLayout, from ...
Cantón's user avatar
  • 33
13 votes
2 answers
485 views

How do I limit the scope of etoolbox environment patching?

I want to use the etoolbox package to patch a certain environment; but - I only want to do it for a certain stretch of my document. Enclosing in curly brances doesn't work: \documentclass{article} \...
einpoklum's user avatar
  • 12.4k
1 vote
2 answers
640 views

Different style for appendix section heading via KOMA-script

I like the use of hanging section numbers in the margin. But when I move to the Appendices, I would like to revert the behavior back to normal. Additionally, I'd like to start the name of the ...
likethevegetable's user avatar