The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
1
vote
1answer
43 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
93 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 \...
1
vote
0answers
52 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
42 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
26 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? \...
0
votes
1answer
96 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
123 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
362 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
58 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
95 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
175 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
232 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
226 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
60 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 ...
17
votes
1answer
699 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
596 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} \...
3
votes
1answer
354 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
570 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
136 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
66 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 ...
5
votes
1answer
621 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
131 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
546 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 ...
5
votes
1answer
4k 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......
14
votes
3answers
2k 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
589 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{\...
3
votes
1answer
275 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
817 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 ...
7
votes
1answer
1k 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
143 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} \...
3
votes
1answer
1k 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
654 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
248 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
3k 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[...
18
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
133 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 ...
3
votes
1answer
332 views

Hooking in before \documentclass

In the consequence of a previously asked question (Is it possible to hook in after options have been processed in a certain package or class?) I had the idea of a hook that adds code even before \...
3
votes
1answer
78 views

Is it possible to hook in after options have been processed in a certain package or class?

In other words: Is it possible to scan the input stream of a .sty or .cls file (without using Perl) for \ProcessOptions\relax and nest some given code afterwords? (The filehook or etoolbox package ...
1
vote
1answer
61 views

Is there any way to hook onto the advancement of a counter?

Question title really says it all - can you hook onto \stepcounter{mycounter} which probably boils down to (I may very well be wrong) \advance \mycounter by 1 Is this a hookable thing? Edit: I'm ...
10
votes
1answer
968 views

Is \AfterEndPreamble really executing code after any \AtBeginDocument code?

The babel package loads the (last) language at begin document, thanks to an \AtBeginDocument command (lines 12.256 and 12.257 of its kernel): \AtBeginDocument{% \expandafter\selectlanguage\...
4
votes
1answer
127 views

Hook tex macro without altering tokens stream

Is is possible to hook a macro with function which writes some info to file or log without altering stream which creates dvi file. For example if i have macro definition \def\foo{\mathop{A}} and i ...
3
votes
1answer
259 views

auctex, hooking into wrapping specific environment

I do a lot of editing using Emacs and auctex, some of this involve wrapping certain parts of the manus with a certain environment. This is quite easy using transient-mark-mode and C-c C-e. But I'd ...
10
votes
6answers
984 views

How can “execute at begin node” be used with special characters like curly braces? (or: how to raise node content)

I'd like to define the following style: test/.style={ execute at begin node={\raisebox\{-0.2cm\}\{}, execute at end node={\}} } and use it like \documentclass{article} \usepackage{tikz} \...
11
votes
1answer
692 views

\AtBeginChapter?

Are there any hooks that work like \AtBeginDocument for chapters, sections, etc.? Something like \AtBeginChapter? I would like to have the following code: \AtBeginChapter{% \setcounter{mycounter}{...
6
votes
2answers
174 views

Weird interaction between everyhook and fancyhdr

In a document I'm working on, I'd like whitespace to be added before a custom environment, but only if that environment doesn't immediately follow a sectioning command (\section, \subsection, etc). I ...
7
votes
1answer
340 views

Force all floats to the end of the document without using endfloat, compatible with htlatex

What is the easiest way to have all floats forcibly appear at the end of the document? The solution should work with htlatex, the floats should appear at the end of the HTML document in this case. (...
8
votes
1answer
885 views

Force all floats to the end of the document without using endfloat

What is the easiest way to have all floats forcibly appear at the end of the document, one per page? The endfloat package is not an option, see below. The following questions are related but not ...
12
votes
2answers
248 views

How can I find out what pages my floats are on (without looking at every page of the document)?

This question led to a new package: chkfloat Making small tweaks to my (two-column) document can result in my floats (both single and double columns) moving all over the place. I know that my ...
5
votes
1answer
438 views

Append the contents of an environment to a hook using \gappto

I have a global hook (=macro) that should be appended to whenever an environment is executed. (Here, defined by the \bhook-\ehook pair.) However, I was unable to derive a working solution. \...