How do I insert a newpage/pagebreak into the pdf output of a Jupyter Notebook using the IPython.display.Latex
function?
nbconvert is used:
nbconvert --to=pdf
A latex cell works fine:
%%latex
\newpage
but this doesn't do anything:
Latex(r"\newpage")
unless it's the last line of the cell (that's why it works when it's in its own cell), it should be:
display(Latex(r"\newpage"))
Further elaborating on the answer of @Julio, what you need to incorporate some latex code into a Code cell is:
from IPython.display import display, Math, Latex
then you can procedurally add Latex syntax or Math in any code cell like:
display(Latex(r"\newpage"))
for math formulas, swap Latex
with Math
.
This will work for scenarios where, e.g., you want to add one line break for each iteration of a for loop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With