Quantcast
Viewing latest article 2
Browse Latest Browse All 3

Answer by Ian Thompson for Reacting to a page break in LaTeX

My original idea was to change the footer at the environment start andrevert it at the end, but this fails if the environment ends whilstTeX is storing material that will ultimately contain a page break(most likely if the environment end ends up near the top of a page).

I think the right way to do this is to put a switch in the footeritself, to detect whether or not the environment is active when thepage is constructed. I've used the fancyhdr package because it makeschanging the footer very easy, but it isn't strictly necessary.Similarly, I've used the geometry package to adjust the pagedimensions and move the end of the environment from place toplace, but this is just for testing purposes. Finally, note that thereis no need to execute \inenvfalse at the end of the environment,because \inenvtrue is local, and the global setting is restored at\end{myenv}.

\documentclass{article}\usepackage[width=16cm,height=20cm]{geometry}\usepackage{lipsum} % For dummy text\usepackage{fancyhdr}\pagestyle{fancy}\newif\ifinenv\inenvfalse\newcommand\myrfoot{\ifinenv PTO \else Hello! \fi}\rfoot\myrfoot\newenvironment{myenv}{\section*{Environment start!}\inenvtrue}{\par\medskip\noindent\centering\rule{0.75\textwidth}{2pt}\par\bigskip}\begin{document}\lipsum[1-8]\begin{myenv}\lipsum[9-16]\end{myenv}\lipsum[17-24]\end{document}

Viewing latest article 2
Browse Latest Browse All 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>