{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

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} ...
11
votes
3answers
519 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 ...
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}% ...
10
votes
1answer
784 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 ...
11
votes
3answers
177 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 ...
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 ...
10
votes
2answers
269 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 ...
9
votes
6answers
379 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} ...
6
votes
2answers
102 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: ...
6
votes
1answer
85 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} ...
6
votes
1answer
197 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. ...
10
votes
1answer
221 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
1answer
105 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
1answer
248 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 ...
3
votes
1answer
140 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
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 ...