-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add page break and chapter name options for printing #1300
Conversation
Thanks! A few questions:
|
|
Improving the print version is great! I am all for this change. As @ehuss said, it is standard practice (but not a requirement) to write the title of the chapter at the beginning of the file as first level heading.
Yes that is right. Generally the chapter title is I would definitely not expect the chapter titles and section titles to have the same level in the printout version (even if it is off by default). What are your thoughts about this? |
From MDN's doc Heading elements:
As it is the preferred practice, I will remove the |
This pr is out-dated, and a new pr #1485 is proposed. |
Background
For now, the only way to export to PDF format is by exporting to HTML and click the print button. However, the printed version simply hide the sidebar and merge all the chapters into one. This can lead to the loss of chapter information.
For example:
Chapter1.md:
Chapter2.md:
The printed version is
We can't determine the paragraph is in which chapter, which may be important for some books.
Solutions
I add two options to solve this problem:
In
book.toml
:First,
page-break
inserts page breaks between chapters. This is a common practice in many markdown editors, such as Typora. To implement this feature, I use CSS property break-before (and page-break- before for compatibility).Second,
chapter-name
inserts chapter name before each chapter.The above two options only works for the printed version (PDF in most case), and will not affect the HTML version.