TeX - LaTeX Asked on September 3, 2021
I want to create a command similar to @startsection
from LaTeX kernel. I need to start new page if the previous body had something and not do it if it was empty.
I looked into kernel documentation, but I don’t understand how @noskipsec
works.
MWE:
documentclass{article}
usepackage{etoolbox}
newtoggle{emptybody}
settoggle{emptybody}{true}
newcommand{mytitle}[1]{%
iftoggle{emptybody}{textbf{#1}}{clearpage textbf{#1}}par
}
begin{document}
mytitle{First title}
mytitle{Should be on the same page}
Text
mytitle{Should be on the new page}
end{document}
documentclass{article}
usepackage{etoolbox}
makeatletter
newcommand{mytitle}[1]{%
ifbool{@nobreak}{textbf{#1}}{clearpage textbf{#1}}parnobreak@afterheading
}
makeatother
begin{document}
mytitle{First title}
mytitle{Should be on the same page}
Text
mytitle{Should be on the new page}
end{document}
Correct answer by Ulrike Fischer on September 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP