Questions tagged [hooks]

{hooks} are macros (or placeholders) stored at specific locations inside other macros that can be redefined to the user's specifications, thereby "hooking into" the macro at that specific point.

Filter by
Sorted by
Tagged with
5
votes
1answer
121 views

storebox not working as expected since texlive 2020

I have to include page-specific content multiple times per page (DM codes to be specific) in a LaTeX document. To that end I use a combination of storebox and everypage such that content is typeset ...
1
vote
0answers
44 views

How to require a LaTeX version that provides the new hooks management system?

A class of mine is loading the biblatex package if the user uses a given option. For this, the class used to rely on \AtEndPreamble{\RequirePackage{biblatex}} and I guess it used to work nicely. It ...
1
vote
0answers
78 views

Package hooks Error: Extra \PopDefaultHookLabel

Recently I moved from Mac to Windows and when I compile the document class nle.cls in Windows, which can be downloaded from this link (it is a journal template), I get lots of errors. I did not have ...
0
votes
0answers
42 views

How can I insert commands when entering into mathmode and when exiting from mathmode?

I want to insert \special's when entering into mathmode and when exiting from mathmode. I wrote the following source code with everyhook.sty: \documentclass{amsart} \usepackage{everyhook} \newcommand{\...
5
votes
2answers
62 views

Display number of sections at the beginning of a chapter

My goal is to display the number of sections the chapter contains, at the beginning of every chapter. Currently, my idea is to store in the aux file the value of the section counter at the end of ...
1
vote
1answer
60 views

How to redefine \\ command inside a tabular using expl3?

When i try to redefine \\ inside a tabular,my redefining not works. I understood,what probably after hook \AtBeginEnvironment something redefine my \\ command,but i dont know,how to fix it. Help me ...
0
votes
1answer
105 views

\src@load@hook undefined error after Miktex update and using

I know it is normal practice to place a MWE, however in this case, I hope by just stating the error, you can help me down some path I can take to resolve this issue. I have been using Harvey Sheppard'...
9
votes
1answer
137 views

\renewenvironment and environment hooks

This question refers to the hook system of LaTeX 2e introduced in October 2020 (lthooks). How does \renewenvironment interact with its hooks? Are the hooks cleared or does the code already added to ...
3
votes
1answer
97 views

Removing the content of a LaTeX hook (using lthooks)

In a special case (new version of the document class leaflet) I use the new LaTeX hook shipout/before to save the finished pages in box registers without output. In the next step they are combined and ...
1
vote
0answers
176 views

CTeX recent update causing problem: \ctex_gadd_hook:Nn \CJKhook { \ctex_set_ignorespaces: }

It was fine by 17th Sep and the file would compile using PDFLaTeX to produce PDF. \documentclass[12pt, a4paper]{ctexrep} \usepackage{amsmath} \usepackage{adjustbox} % uses graphicx \usepackage[top=1....
0
votes
1answer
91 views

Re-defining `\\`

EDIT: The original version of this was a foolish question; @egreg points out that I was thinking of {amsmath}'s matrix environment. I'm sure that this has been asked before, but it's hard to search ...
1
vote
1answer
45 views

\AtEndPreamble hook breaks hyperref with bibliography

In the past I used \usepackage{hyperref} within the \AtEndPreamble{} hook, without problems. At least I think so. However, recently the hook breaks the links to my bibliograpy. Is that a bug or am I ...
5
votes
1answer
66 views

How to work with members of sequence during iteration with expl3?

I have several environments before and after which I want to insert identical code. I want to do this using expl3 because in my opinion it is the best solution. But my solution does not work because ##...
2
votes
1answer
59 views

Hooking an environment inside `document` environment

I am making a beamer-document that is basically a one-page frame. Since don't want to explicitly call the frame inside the environment, I how \begin{frame}[t] at the beginning of the document and \end{...
4
votes
3answers
158 views

Add material to a macro with parameter

I'm trying to define a macro \addtohook that adds material to another macro \hook, similar to LaTeX's \addto@hook, but where \hook takes a parameter. So if \hook is empty at start, after a series of \...
3
votes
1answer
192 views

How to run a command before compiling (hook script) in latexmk?

I use latexmk to compile a project. It should run some bash commands before starting to compile. I tried to add $compiling_cmd="date >> /tmp/compiled.log"; to the local .latexmkrc file. But ...
0
votes
1answer
52 views

Automatically drawing frames around document elements with LaTeX

I wonder how to draw frames around various elements in LaTeX (or LuaLaTeX if needed)? I would like to get frames around every text paragraph, and/or every equation, every image, every header, every ...
1
vote
1answer
33 views

\AtEndOfEveryFile is executed in \begin{itemize}

I was quite surprised that the \AtEndOfEveryFile hook defined by the filehook package is executed in \begin{itemize}. Is this behaviour intended? If not, how and where do I file a bug report? \...
2
votes
1answer
133 views

ConTeXt: What are alternatives and rendering setups?

I've seen the alternative keyword used throughout ConTeXt: \setuppagenumbering[alternative=doublesided] \setupheads[alternative=inmargin] \setuplist[section][alternative=d] I assumed that it was ...
2
votes
2answers
138 views

Extra space at the end of the document added by PGF

As seen in this answer to my previous question “Extra vertical space at end of last column when loading adjustbox (only luatex)”, loading the package pgf causes the following to be added at the end of ...
7
votes
1answer
586 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} ...
0
votes
1answer
67 views

Hooks for many hypotheses or conclusions

Good morning! How can I do this? Thank's a lot!!! EDIT The below answer has this problem:
1
vote
0answers
118 views

KOMA-Script list of hooks [closed]

I'm currently trying to find the chapter name with KOMA-Script and probably need a hook for that. Is there a list with all the available hooks? Does anyone have better suggestions to do this? Thank ...
1
vote
2answers
1k views

How to check successful compilation in PDFLaTeX?

I want to develop a pre-commit hook for my LaTeX Git repository. I need the hook to suppress the commit in case the compilation finishes unsuccessfully (missing packages OR missing source files OR ...
12
votes
1answer
192 views

What is the (relevant!) difference between \file_input:n and \input? Or has something else changed?

A while ago I answered a question with code which attempts to set the name of an externalised image, produced with TikZ's external library, to something based on the name of the input file. That ...
0
votes
2answers
355 views

Add a command to every display mode math equation

Is it possible to have a hook in every display math mode, before and after the formula? For example: if I would like to make every display formula 50% smaller, I would ask the hook on entering the $$ ...
3
votes
1answer
684 views

Conditional \if \fi using hooks \AtBeginDocument and \AtEndDocument

I wonder if there's a way in LaTeX to create a conditional in the whole document from the preamble? Something similar to this sample (which obviously does not work): \documentclass{article} \...
2
votes
0answers
67 views

Collecting and analyzing data presented in tables

I have data presented in tabular environments and I want to process it, in LaTeX, in ways that require for multiple cells to be analyzed together. That's in addition to typesetting the cells ...
19
votes
1answer
985 views

What is exactly a hook in etoolbox

I understand well the \apptocmd and related tools of etoolbox package. However, I still not understand what \appto<hook>{<code>} and related do, even reading three time the handbook ? ...
2
votes
1answer
912 views

Loading BibLaTeX from within the AtEndPreamble hook

The following MWE compiles: \documentclass{article} \usepackage{biblatex} \begin{document} \end{document} whereas the following does not: \documentclass{article} \usepackage{etoolbox} \...
5
votes
1answer
538 views

Post compile hook latexmk

Is there something like a "post compile hook" for latexmk. I want to configure latexmk to run some scripts automatically after a compilation process is completed.
4
votes
1answer
777 views

Automatically run code at end of file

In typical LaTeX documents, the document content is typed inside the document environment, which is usually the last thing in the file: \documentclass{article} \begin{document} Content goes here....
5
votes
2answers
166 views

\BeforeEndgroup similar to \AfterGroup?

Is there a command similar to etextools' \AfterGroup which allows to execute a number of commands right before, not after the current group ends?
1
vote
1answer
72 views

Problems using hooks

I am trying to duplicate a document using hooks at the beginning and the end. Here is a minimal example of my problem : \documentclass{minimal} \usepackage{environ} \usepackage{forloop} %Repeat ...
6
votes
1answer
737 views

\AtBeginEnvironment not accepting parameters in the code

etoolbox's docs say in the section on environment hooks: Parameter characters in the code argument are permissible and need not be doubled. However, this won't compile: \documentclass{article} ...
2
votes
1answer
148 views

A clean interface for hooking into sectioning commands

Is there an easy way to hook LaTeX's sectioning commands, short of the good ol' \let + \def (or, with xparse, \let + \RenewDocumentCommand{s O{} m})? I'm looking for something in the spirit of ...
3
votes
2answers
1k views

Adding \comment or \begin{comment} to \AtBeginDocument?

For Partial compilation commands/environment?, I would like to add \begin{comment} or \comment at the start of the document (so I could turn it off elsewhere in the code). So, even if in the larger ...
6
votes
1answer
5k views

How to set one header for each page using multicols

I want to use multicols in my document and also having a small box on each page (upper left) to be drawn automatically. I already tried \AtBeginPage hooks but the box didn't print at proper position......
15
votes
3answers
3k views

Why won't \AtEndDocument execute at the *end* of the document?

I must be doing something incredibly stupid, but I've boiled it down just as far as it can go with no luck. I'm working on a bug that's cropped up in a recent commit in pagectrl @ca7dc3. I have the ...
6
votes
2answers
632 views

Purpose of AtEndDocument{\def}

I am currently researching how to generate a recompilation warning from Latex if somthing in the auxfile changes and found this solution. However I find it rather confusing, it uses: \AtEndDocument{\...
4
votes
1answer
341 views

How can I output before the final clearpage using AtEndDocument or similar?

I would like to output a single line of text at the end of all the documents generated using a particular coustom package file. I assumed \AtEndDocument would do the trick as I have used it before to ...
6
votes
1answer
891 views

Errors when loading a package with AtEndPreamble hook

Consider the following (not so) MWE: \documentclass{article} \usepackage[style=authoryear-comp,backend=biber]{biblatex} \addbibresource{biblatex-examples.bib} \makeatletter % Load xpatch and ...
8
votes
1answer
2k views

What is a hook - everypage package

The everypage package speaks of hooks. What exactly is meant by this and how could it be used?
5
votes
1answer
148 views

Figure one next to the other and hook to equation's points

I would like to connect two figures like the following. The code that I've already have is: \documentclass{article} \usepackage[english]{babel} \usepackage{ucs} \usepackage[utf8x]{inputenc} \...
4
votes
1answer
2k views

Where to put \renewcommand in Beamer

This question is related to Setting default overlay specification for itemize environment. In the above-linked question, Werner provided a solution that uses \LetLtxMacro and \renewcommand. However, \...
3
votes
1answer
983 views

\afterpage not called after page break

In this example \documentclass{article} \usepackage[a6paper,landscape,margin=1cm,bottom=2cm]{geometry} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{afterpage,refcount,lastpage} \...
7
votes
1answer
309 views

How can I test the first character on each line of a listing?

The listings package defines a hook called EveryLine to allow users to execute TeX code at the beginning of each line of a listing; the following is taken directly from the listings source code (...
5
votes
2answers
4k views

\AtBeginDocument and \AtEndDocument for standalone

Using the commands \AtBeginDocument and \AtEndDocument with the standalone documentclass yields unexpected effects. I have the following three files. % main.tex \documentclass{scrartcl} \usepackage[...
21
votes
2answers
3k views

All about \shipout

While reading about packages that allow to hook macros to certain events, I came across this command, \shipout. Searching on the internet didn't help a lot but if I'm not so wrong it's somehow related ...
5
votes
1answer
145 views

datatool: How to reliably store database in \AtEndDocument (or similar hook)

In a big report with many subfiles and authors, I am using the datatool package to write out some data collected across the document. At the end of the document, the data should be stored in a CSV ...