{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.

learn more… | top users | synonyms

3
votes
2answers
38 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: ...
2
votes
1answer
23 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 ...
4
votes
0answers
44 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 ...
5
votes
1answer
91 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?
6
votes
1answer
82 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
121 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, ...
2
votes
0answers
74 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} ...
6
votes
1answer
104 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 ...
3
votes
2answers
588 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} ...
12
votes
2answers
464 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
77 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 ...
2
votes
1answer
204 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
59 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
45 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: ...
10
votes
1answer
214 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{% ...
3
votes
1answer
100 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
155 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 ...
9
votes
6answers
369 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} ...
10
votes
1answer
218 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{% ...
6
votes
2answers
113 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 ...
6
votes
1answer
196 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. ...
5
votes
1answer
243 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
194 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 ...
4
votes
1answer
154 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. ...
8
votes
1answer
338 views

calc package incompatible with \setlength in \g@addto@macro?

I want to systematically have some indentation in \parboxes and minipage environments. To do this, I add the following code in the preambule of my LaTeX file: \makeatletter ...
10
votes
3answers
170 views

Can I hook into the end of the document but *after* the `\clearpage`?

The code for \enddocument begins: \def\enddocument{% \let\AtEndDocument\@firstofone \@enddocumenthook \@checkend{document}% \clearpage \begingroup I'd like to put something after ...
9
votes
1answer
1k views

Frame Numbers in Beamer's Article Mode

I'm using the beamer package to create a presentation. Additionally I'd like to have a handout containing more information (as presentation slides should not contain much text). For this I use the ...
10
votes
1answer
757 views

How to extend the \lstinputlisting command

With the answer from autogobble for lstinputlistings I've managed to create a command that gobbles \lstinputlisting and makes firstnumber to start by firstline. I would like to rewrite it as a ...
6
votes
2answers
820 views

\AddEverypageHook just checks the first page

I am totally new to LaTeX and right now I'm trying to find out how everything works. For the following code I get a background picture only on the first page although I want to have it on all odd ...
9
votes
2answers
207 views

Hooks into mathmode

Short version Is there a way to pipe every symbol in a math environment unevaluated to an external program w/o manipulating the (La)TeX file directly (except for adding header files) or patching TeX ...
5
votes
1answer
247 views

Hooking into the header/footer mechanism

I have a switch I'd like to turn off for the headers and footers but keep on for the main body text. What commands actually tell TeX to write the headers and footers after the body text has been set ...
10
votes
2answers
266 views

Place TikZ coordinate or \zlabel at every (base)line

I'm currently adjusting the code shown in Test if a paragraph has a page break in it? to support underlining and highlighting using TikZ similar as shown in Cool Text Highlighting in LaTeX, but ...
10
votes
3answers
515 views

Shell escape after PDF is finished and closed?

I like to escape to the shell using \write18 at the very end of the compilation after the PDF file got completely written and was closed, so that I can use it as part the shell command. Is this ...
5
votes
1answer
174 views

Is it possible to add hooks to the three main logical divisions in memoir?

I want to prepare a style based on memoir that executes code immediately before and after frontmatter, mainmatter, and backmatter (ยง6.1, pg.71). Without hooks, I have to insert the code in the Latex ...
27
votes
2answers
2k views

How to automatically add text immediately after \begin{document}

I attempted to redefine the document environment as follows, but get a complaint that: LaTeX Error: \begin{MYdocument} on input line 13 ended by \end{document}. \documentclass[12pt]{article} ...
2
votes
2answers
425 views

Why does \everydisplay conflict with gather and multline

When gather* is used together with \everydisplay an error is produced. Is there a possibility to make these work together? Minimal working example: \documentclass{ctexart} \usepackage{amsmath,color} ...
15
votes
2answers
1k views

How to add a hook to a macro

LaTeX uses hooks extensively, one method employed is the command g@addto@macro. It is defined in source2e as: \long\def\g@addto@macro#1#2{% \begingroup \toks@\expandafter{#1#2}% ...