Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [patching]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
28 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*...
user avatar
0 votes
0 answers
24 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} % \...
user avatar
  • 1,121
0 votes
1 answer
32 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 ...
user avatar
  • 413
0 votes
1 answer
46 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, ...
user avatar
  • 5,511
6 votes
4 answers
190 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: \...
user avatar
2 votes
1 answer
44 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<+...
user avatar
1 vote
1 answer
28 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\...
user avatar
  • 5,511
4 votes
1 answer
73 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 ...
user avatar
  • 5,511
1 vote
1 answer
33 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@...
user avatar
  • 5,511
1 vote
1 answer
40 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 ...
user avatar
  • 5,053
2 votes
1 answer
203 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} \...
user avatar
1 vote
0 answers
29 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} ...
user avatar
5 votes
2 answers
132 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} \...
user avatar
  • 16k
0 votes
1 answer
33 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 ...
user avatar
  • 512
2 votes
1 answer
55 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 ...
user avatar
  • 5,053
1 vote
1 answer
35 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 ...
user avatar
  • 281
0 votes
1 answer
46 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 ...
user avatar
  • 281
1 vote
3 answers
135 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} \...
user avatar
3 votes
2 answers
128 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 ...
user avatar
  • 33
1 vote
1 answer
35 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 ...
user avatar
  • 3,866
3 votes
3 answers
238 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][\...
user avatar
7 votes
0 answers
230 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 ...
user avatar
  • 1,944
0 votes
0 answers
49 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....
user avatar
0 votes
0 answers
51 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 ...
user avatar
  • 12.5k
1 vote
1 answer
186 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 ...
user avatar
  • 667
2 votes
1 answer
139 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 ...
user avatar
  • 695
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,...
user avatar
3 votes
1 answer
283 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 ...
user avatar
0 votes
0 answers
70 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. ...
user avatar
  • 16k
3 votes
1 answer
92 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 ...
user avatar
  • 33
13 votes
2 answers
373 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} \...
user avatar
  • 11.3k
1 vote
2 answers
439 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 ...
user avatar
2 votes
1 answer
169 views

How to add code at beginning of every chapter?

I would like to add code at the beginning of every chapter. In particular, the \minitoc command. I hoped \appto would do the trick. But no luck. \usepackage{etoolbox} \appto\chapter{Test} Just uses ...
user avatar
  • 1,687
8 votes
3 answers
488 views

Why does this regexpatch command only work once, not twice?

Based on an early version of How can I add a single curly brace to a macro?, I have tried the following to add, one by one, inner commands to some outer command. (The reason I am doing this is that I ...
user avatar
  • 5,122
2 votes
1 answer
52 views

Turn string into macro (change catcodes)

Is it impossible to covert string back into macro? I know that with lualatex we can do a lot of funny things with macros. I have never seen string converting without it. \documentclass{article} ...
user avatar
0 votes
2 answers
223 views

How to patch \href to look like \url?

There are at least two questions, that ask for this without mentioning it explicitly, so there we go. Neither this nor actually answer the questions, how to make \href style the same way as \url - ...
user avatar
  • 751
0 votes
0 answers
103 views

Empty the pagestyle for last parts of my report document

I have patched in my preamble the command \chapter with the package etoolbox so as to get a defined style for all my chapters \patchcmd{\chapter}{plain}{mystyle}{}{}. (I am using the fancyhdr package )...
user avatar
2 votes
2 answers
143 views

Patch `\includegraphics` to call `\embedfile`

I want to make a package that automatically attaches all essential*) source files to the ouput PDF. I started with the embedfile, filehook and currfile packages and put \embedfile\currfilename \...
user avatar
  • 484
2 votes
1 answer
934 views

How to color half page?

I used color to color my page. I want a horizontal (halfway) colored patch which begins from the midpoint and ends at the right end of the page. (Only for the first page and not for the complete ...
user avatar
  • 2,203
3 votes
2 answers
471 views

Capitalize first letter of words in chapter mark

I would like to capitalize the first letter of several words in the chapter and the chapter mark. While text in the chapter itself is capitalized, in the chapter mark it is not. Here is a MWE of my ...
user avatar
  • 2,031
2 votes
2 answers
189 views

remove "./" of "\currfileabspath" when using lualatex

I have a small problem with the package currfile and the command \currfileabspath. When compiling the file using (pdf|xe)latex I get the expected result, but if I use lualatex it adds ./ to the ...
user avatar
4 votes
2 answers
650 views

Strange result with patch of \overarc

Triying to use a patch for \overarc from this answer https://tex.stackexchange.com/a/409106/54817 I got this result \documentclass{article} %\usepackage{fix-cm} \usepackage{arcs} \usepackage{...
user avatar
  • 16k
2 votes
2 answers
156 views

moderncv package does not recognize \it command

The moderncv package does not recognize \it command. Sure we can use \textit instead. The problem is that BibTeX generated files may contain \it commands ... So, edition of the bbl file is required ...
user avatar
1 vote
1 answer
126 views

Pass option to each occurence of command (especially \printbibliography with biblatex)

In a large book with many sub-bibliographies, I want to ensure that crucial bibchecks are executed at every call to \printbibliography. Normally, one would simply call \printbibliography[check=...] ...
user avatar
3 votes
0 answers
154 views

pdfx and biblatex attempt to patch the same things? [closed]

The below MWE gives errors. Moving the line \usepackage{pdfx} below the biblatex package (right before \begin{document}) will currently not give explicit errors, but “it is best if pdfx is the first ...
user avatar
  • 916
0 votes
1 answer
176 views

How can I patch the abstract, list of figures, and list of tables macros to be included in the ToC automatically?

We can definitely use \phantomsection \addcontentsline{toc}{chapter}{<name>} right after we begin the environments or type the relevant macro, which would include abstract, list of figures and ...
user avatar
0 votes
1 answer
98 views

Adding transparent characters into class-defined macros

This question is related to a previous question regarding machine readability of a PDF generated using moderncv. I'm trying add some hidden description within the PDF, so the information is not ...
user avatar
  • 554
3 votes
1 answer
169 views

regexpatch \xpatchcmd fails in patching command begins with space

The \xpatchcmd provided by regexpatch fails in patching command which begins with space. The same \xpatchcmd provided by xpatch works alright. Some version info: XeTeX 3.14159265-2.6-0.99999 ...
user avatar
  • 20.7k
7 votes
1 answer
828 views

Add command at the beginning of all frames

I need to add a command \setRTL from the bidi package to write right-to-left text, at the beginning of every frame. Another answer does not solve the issue; any suggestions? \documentclass{beamer} ...
user avatar
  • 16k
1 vote
1 answer
150 views

Patching tikzscale

I'm trying to patch the package tikzscale. Specifically, I want to remove the following lines from the package, as it does not constitute a useful error in my usecase[1]. \tikzscale@ifSizeDifference{\...
user avatar
  • 111