Styles For Printer-Friendly Pages
Here are the key styles that can be applied for creating printer-friendly pages:
- Simplify the Layout: Remove unnecessary elements like sidebars, navigation menus, advertisement sections and interactive content by setting display as none
- Remove Background Colors: It is recommended to remove background color (or set light color) and set text color as black for printable version of pages. This helps to save ink.
- Adjust Font Sizes and Styles: Use readable font sizes and styles, typically larger and more legible fonts like serif fonts.
- Display URLs for Links: When you print a page containing hyperlinks, the exact URL for that will not be visible. So you need to replace this with exact link on printable version.
- Manage Page Breaks: Make sure to control where content breaks between pages to avoid splitting important sections or headings across pages.
Below are CSS examples. If you want to include them in your TiddlyWiki, add them to a stylesheet tiddler or create a new tiddler tagged with
$:/tags/Stylesheet
.
Hide TiddlyWiki Elements
@media print {
/* hide extra element */
.tc-titlebar, /* hide title and icons on title */
.tc-subtitle, /* hide subtitle including date */
.tc-tags-wrapper, /* hide tags */
.kk-utility-details /* hide source button - Utility plugin*/
{ display:none; }
}
Add Page Size and Margin
@page {
size: A4 portrait; /* A4 size, portrait orientation */
margin: 2cm; /* 2cm margins on all sides */
}
/* First page has different styling */
@page :first {
margin: 5cm;
}
Page Background and Color
If you print with a black and white printer use below CSS.
@media print {
body{
background-color: white;
color: black;
}
Page Breaks
You may like start every tiddler in a new page, so use proper page breaks.
/* https://talk.tiddlywiki.org/t/print-css-for-tiddlers/12489/9 */
@media print {
.tc-tiddler-frame { break-after: page; }
.tc-tiddler-frame:last-of-type { break-after: avoid; }
}
Show URLs of links
Turn links like “Transclusion” into “Transclusion (https꞉//en.wikipedia.org/wiki/Transclusion)”. This does not transform internal links.
@media print {
a[href]:not([href^="#"]):after {
content: " (" attr(href) ") ";
/* text-decoration: underline; */ /* if you want those links to be underlined in the print */
}
}
References
For advanced users. If you wish to explore further, you may consider reviewing the references provided below.
This CSS module specifies how pages are generated and laid out to hold fragmented content in a paged presentation. It adds functionality for controlling page margins, page size and orientation, and headers and footers, and extends generated content to enable page numbering and running headers / footers.