Skip to main content

Questions tagged [patching]

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

Filter by
Sorted by
Tagged with
5 votes
3 answers
165 views

How to patch (redefine) the standalone's \subpreamble command?

I'd like to patch (redefine) the standalone's \subpreamble command but my attempts seem to fail. Here's an MCE that I expect to fail to compile because of the \aaa command, but it doesn't: \begin{...
Denis Bitouzé's user avatar
5 votes
3 answers
385 views

Applying a Little Artificial Intelligence to a Patched Titlecaps Algorithm

This question is based on @StevenB.Segletes' patch for titlecaps found here: Reformatting a Paragraph Consisting Entirely of Capital Letters Consider the code: \documentclass[12pt]{article} \...
DDS's user avatar
  • 10.4k
4 votes
2 answers
115 views

How to patch command to work differently in math mode?

I am using starfont to get astronomical symbols in my document. Unfortunately, the package defines the symbols for text mode only. From this answer, I was able to declare math versions of the symbols ...
Shai Avr's user avatar
  • 983
2 votes
0 answers
57 views

Frankenstein’s Conscience conflicting with tabular environment? How to patch?

I'm using compsci and friends for a LaTeX course. But the following MWE \documentclass{article} \usepackage{compsci} \begin{document} Well, the following works: ``\cs\_'' % but there's an extra ...
gildux's user avatar
  • 538
0 votes
0 answers
89 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
  • 2,022
6 votes
2 answers
197 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
43 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
4 votes
2 answers
182 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,454
0 votes
1 answer
39 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
73 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
22 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
  • 612
0 votes
2 answers
75 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,605
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
273 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
1 vote
1 answer
65 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
98 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
60 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.2k
1 vote
0 answers
44 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
2 votes
1 answer
69 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
62 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
95 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
  • 9,458
0 votes
0 answers
51 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
81 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
  • 10.4k
0 votes
0 answers
51 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,390
1 vote
1 answer
127 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
  • 693
0 votes
1 answer
86 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
  • 9,022
6 votes
4 answers
376 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
70 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
  • 9,022
4 votes
1 answer
150 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
  • 9,022
1 vote
1 answer
47 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
  • 9,022
1 vote
1 answer
222 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
  • 9,458
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
184 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.2k
0 votes
1 answer
75 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
  • 624
2 votes
1 answer
193 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
  • 9,458
1 vote
1 answer
77 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
  • 445
0 votes
1 answer
100 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
  • 445
1 vote
3 answers
293 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
  • 107
3 votes
2 answers
285 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,918
3 votes
3 answers
475 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
303 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,321
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
63 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
  • 15.7k
1 vote
1 answer
510 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
242 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
  • 1,077
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
4 votes
1 answer
715 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