General ⇒ How can I tell when I'm inside a footnote?
How can I tell when I'm inside a footnote?
Is there an environment variable that I could test for?
All ideas much appreciated.
Thanks
Alan
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
-
- Posts: 351
- Joined: Sat Aug 02, 2008 8:47 am
How can I tell when I'm inside a footnote?
alanq wrote:I have a customized command that I need to make operate differently when inside a footnote.
Is there an environment variable that I could test for?
Code: Select all
\documentclass[12pt]{article}
\newif\ifinFN\inFNfalse
\makeatletter
\let\@Footnotetext\@footnotetext
\renewcommand\@footnotetext[1]{%
\global\inFNtrue\@Footnotetext{#1}\global\inFNfalse}
\makeatother
\def\Test{\ifinFN in \else not in \fi footnote}
\begin{document}
\textsf{\Test}
\footnote{foo \Test \par bar \Test}
\Test
\end{document}
How can I tell when I'm inside a footnote?
Thank you.
I'm relatively new to TeX/LaTeX, but already a fan, so learning how all that works will add much to my armoury

I have Knuth's Volume A on it's way...
Regards
Alan
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How can I tell when I'm inside a footnote?
Best regards
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10