The idea is to replicate the PDF output on rmarkdown in quarto, in this case, is creating a multiple-page orientation on a single document. In rmarkdown I can do it easily by using this trick. However, I could not do that in quarto, it keeps sending the error message
compilation failed- error
Undefined control sequence.
l.201 \blandscape
Here is my code:
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
- packages.tex
---
# Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
\newpage
\blandscape
# Running Code
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
You can add options to executable code like this
The `echo: false` option disables the printing of code (only output is displayed).
\elandscape
Interestingly, I can create a multiple page orientation by modified the YAML and inserting raw latex to start and end the landscape page, but it will erase all the rmarkdown formatting and turned it into normal text inside the landscape page:
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
text: |
\usepackage{pdflscape}
---
\begin{landscape}
bla bla bla
\end{landscape}
Is there any workaround on this matter?
PS: my header.tex contains this stuff
\usepackage{pdflscape}
\newcommand{\blandscape}{\begin{landscape}}
\newcommand{\elandscape}{\end{landscape}}
Option 01
You can use lscape LaTeX package. This rotates the page contents but not the page number.
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
text: |
\usepackage{lscape}
\newcommand{\blandscape}{\begin{landscape}}
\newcommand{\elandscape}{\end{landscape}}
---
# Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
\newpage
\blandscape
# Running Code
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
You can add options to executable code like this
The `echo: false` option disables the printing of code (only output is displayed).
\elandscape
Option 02
You can also use typearea package of KOMA-Script to do this. To my understanding, It not just changes the page contents orientation, but also sets the pdf page rotation attribute in such a way that pages with this attribute will be displayed in landscape orientation when viewing with PDF viewers. And also preserves the page number position.
---
title: "Portrait and Landscape"
format:
pdf:
include-in-header:
text: |
\usepackage{typearea}
---
# Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
\newpage
<!-- changing the orientation to landscape --------------------------------- -->
\KOMAoptions{paper=landscape,pagesize}
\recalctypearea
# Running Code (Landscape)
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
You can add options to executable code like this
The `echo: false` option disables the printing of code (only output is displayed).
\newpage
<!-- % changing the orientation to portrait again -------------------------- -->
\KOMAoptions{paper=portrait,pagesize}
\recalctypearea
# Quarto (Portrait)
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
Related
I would like to set different sizes and styles of the free overpass font for the H1 & H2 headers in my document.
Using this answer I was able to successfully specify Overpass for all headings in my document but have not been able to isolate specific headings (e.g., chapter, section, paragraph as laid out in the Koma script.
I tried implementing the syntax from this solution used to specify times roman for all heading fonts, but got an error that reads "Package scrkbase Error: font of element `chapter' can't be used.".
Looking at the quarto forum and this tex post, I tried adding the xltxtra packages and setting \newfontfamily, but still no luck.
Ultimately, I would like to use the overpass extra bold font and specify different sizes, but i'm unsure if this is because the syntax to specify the heading section in the YAML is wrong, or if I need to do something else to add a font that is not already built in.
format:
pdf:
mainfont: Calibri
sansfont: Overpass
include-in-header:
text: |
\usepackage{xltxtra}
\newfontfamily\overpass{Overpass}
\usekomafont{chapter}{\Overpass-ExtraBold}
standalone: false
toc: true
editor: visual
tbl-colwidths: auto
include-in-header:
text: |
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{\includegraphics[width = .25\textwidth]{logo.png}}
\cfoot{\thepage}
\usepackage{float}
We can create new commands like \sectionfont or \subsectionfont for loading a particular font family with \newfontfamily (read the fontsepc manual, p-13 to know the details) and then use that command \addtokomafont to apply that font-family to a specific element like (section, subsetion, etc.)
---
format: pdf
mainfont: "Calibri"
include-in-header:
text: |
\newfontfamily\sectionfont[Color=ff7832]{Libertinus Sans}
\newfontfamily\subsectionfont[Color=MediumBlue]{Comic Sans MS}
\newfontfamily\subsubsectionfont[Color=Green]{Roboto Mono}
\addtokomafont{section}{\sectionfont}
\addtokomafont{subsection}{\subsectionfont}
\addtokomafont{subsubsection}{\subsubsectionfont}
---
# H1 heading (section)
## H2 heading (subsection)
### H3 heading (subsubsection)
Quarto enables you to weave together content and executable code into a
finished document. To learn more about Quarto see <https://quarto.org>.
I have a Julia Markdown file (jmd).
---
title: My Title
output: pdf_document
---
```julia echo=false
6+4
```
How can I transport information to LaTex? For example I would like to set the paper orientation to landscape or decrease the font size or similar. I thought be there must be something similar to Rmarkdown, something like
---
title: My title
output:
pdf_document:
toc: true
number_sections: true
documentclass: article
classoption: landscape, a3paper
---
But it does not work in jmd files. Anyone a clever idea?
Setting Configurations on Two Fronts
Weave Options
weave_options can be specified in a Julia Markdown Document's front matter. These are options that might otherwise be passed to the weave function as keyword arguments (configuration in front matter takes precedence over function call options). E.g., one can define the doctype and highlight options. Optionally, one may also define a custom latex template. The following front matter would set these options.
---
title: My Title
author: Me
date: March 21, 2022
weave_options:
doctype: pandoc2pdf
highlight: pygments
template: relative/path/to/custom.tpl
---
Pandoc Options
Assuming that your working with doctype: pandoc2pdf or doctype: pandoc2html then you can also set Pandoc options by passing them as a vector of strings to the pandoc_options keyword argument of the weave function. E.g., for a table of contents and numbered sections one could run the following.
weave("test.jmd", pandoc_options=["--toc", "-N"])
\begin{figure}[ht]
\begin{center}
\includegraphics[height = 3.5\textheight, width = 3.0\textwidth]{fig/InterfaceEMF2ASMFOR}
\end{center}
\caption{list of global parameters customer, FRD versions} \label{fig: limit}
\end{figure}
is the code I have used in my Latex file.
NOTE: {fig/InterfaceEMF2ASMFOR} is a pdf file
After the pdf report got generated the included {fig/InterfaceEMF2ASMFOR} does not look good and not fit to the page in PDF report.
The inserted pdf always loose some portion of it and always inserted from the middle of the page but not from the edges of the page.
Please help me how to fit the fig to the PDF I am creating.
You can include the whole pdf page with the pdfpages package:
\documentclass{article}
\usepackage{pdfpages}
\begin{document}
test
\includepdf{example-image-a4}
text
\end{document}
I have a pdf that I would like to impose. It has 8.5x11" pages, media box, and crop box. I want the pdf to have 17x11" pages, by merging adjacent pages. Unfortunately, most pages have content either completely outside or straddling the crop box. Because each page can only have a single stream and crop box, when imposed, the overlapping content becomes visible. This is bad.
I don't want to rasterize my pdf because that would fix the DPI ahead-of-time. So I won't consider exporting pages as images, appending the images (imagemagick), then embedding these paired images into a new pdf.
I've also had problems imposing in postscript - issues with transparency, font rasterization, and other visual glitches during the pdf->ps->pdf conversions.
The answer should be scriptable.
So far I've tried:
podofo imposition scripts (lua)
PyPDF2 (python)
ghostscript
latex
The question "Ghostscript removes content outside the crop box?" suggests that ghostscript's pdfwrite module, when generating an output pdf file, will rasterize and crop content according to the crop box. So I'd only have to pipe my pdf through ghostscript's pdfwrite module. Unfortunately, this doesn't work.
I was about to give up when I tried printing the pdf to another pdf through evince. It works perfectly - text & vector elements within the crop box are not rasterized, and elements outside the crop box are removed (I haven't tested straddling elements yet). The quality is high - resolution (page size) and appearance are identical. In fact, everything seems to be the same except for the metadata.
So:
the question is possible
the answer already exists
How can I access it?
I think this functionality might be provided by cup's pdftopdf binary. I don't have any problems calling an external binary.... but can't figure out how to use pdftopdf.
Edit: Link to test pdf. It contains raster, vector, and text items - some partially occluded by partially transparent items - that span as well as abut adjacent pages. Once again, printing this PDF through cups appears to crop all content outside the crop box. However, opening the filtered pdf in inkscape shows that the off-page items are individually masked, not cropped - except text, which is trimmed.
The trick is to use Form XObjects to impose multiple pages within a single page. Form XObjects can reference entire PDF pages, and maintain independent clips. PyPDF2 doesn't support Form XObjects, so merging unifies the stream of all input pages such that they share the clip/media box of the output page. I've been successful in using both pdflatex and pdfrw (python) - test programs are inlined below. Since Form XObjects are derived from a similar postscript level 2 feature, as suggested by KenS it should be possible to achieve the same goal in ghostscript using "page clips". In fact he shared a ghostscript 2x1 imposition script in another answer, but it appears horrendously complicated. Combined with the font rasterization issues of poppler's pdftops (even with compatibility level > 1.4), I've abandoned the ghostscript approach.
Latex script derived from How to stitch two PDF pages together as one big page?. Requires pdflatex:
\documentclass{article}
\usepackage{pdfpages}
\usepackage[paperwidth=8.5in, paperheight=11in]{geometry}
\usepackage[multidot]{grffile}
\pagestyle{plain}
\begin{document}
\setlength\voffset{+0.0in}
\setlength\hoffset{+0.0in}
\includepdf[ noautoscale=true
, frame=false
, pages={1}
]
{<file.pdf>}
\eject \paperwidth=17in \pdfpagewidth=17in \paperheight=11in \pdfpageheight=11in
\includepdf[ nup=2x1
, noautoscale=true
, frame=false
, pages={2-,}
]
{<file.pdf>}
\end{document}
pdfrw (python script) derived from pdfrw:examples:booklet. Requires pdfrw >= 0.2:
#!/usr/bin/env python3
# Copyright:
# Yclept Nemo
# 2016
# License:
# GPLv3
import itertools
import argparse
import pdfrw
# from itertool recipes in the python documentation
def grouper(iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return itertools.zip_longest(*args, fillvalue=fillvalue)
def pagemerge(page, *pages):
merged = pdfrw.PageMerge() + page
for page in reversed(list(itertools.takewhile(lambda i: i is not None, reversed(pages)))):
merged = merged + page
merged[-1].x = merged[-2].x + merged[-2].w
return merged.render()
parser = argparse.ArgumentParser(description='Impose PDF files using Form XOBjects')
parser.add_argument\
( "source"
, help="PDF, source path"
, type=pdfrw.PdfReader
)
parser.add_argument\
( "-s", "--spacer"
, help="PDF, spacer path"
, type=lambda fp: next(iter(pdfrw.PdfReader(fp).pages), None)
)
parser.add_argument\
( "target"
, help="PDF, target path"
)
args = parser.parse_args()
pages = args.source.pages[:1]
for pair in grouper(args.source.pages[1:], 2):
assert pair[0] is not None
pages.append(pagemerge(pair[0], args.spacer, pair[1]))
# include metadata in target
target = pdfrw.PdfWriter()
target.addpages(pages)
target.trailer.Info = args.source.Info
target.write(args.target)
Some idiosyncrasies as of pdfrw 0.2:
Note that the operations +=, append and extend are not defined for pdfrw.PageMerge, even though it behaves like a list. Furthermore + acts like += in that it modifies the left-hand-side object.
Ghostscript and the pdfwrite device do not, in general, rasterise the content of input PDF files (the caveat is for cases involving transparent input and the output being < PDF 1.4).
Object which are entirely clipped out are not preserved into the output.
So the short answer is that this should be entirely feasible using Ghostscript and the pdfwrite device, with the advantage that its possible to impose the pages as well in a single operation. I do have an open bug report about clipping in a similar situation (reverse imposition) but have not yet had time to address it.
Note that Ghostscript normally uses the MediaBox for the clip region, if you want to use the CropBox then you need to add -dUseCropBox to the command line.
Has anyone put together a plugin or tool for exporting a Tiddlywiki to pdf?
No, there isn't.
As a workaround, I write or find a decent printable stylesheet, then print to PDF.
Why not select the target tiddler to "Open in new window", and print it to PDF with any installed PDF printer?
To accomplish this I used a tool to convert HTML to PDF. These steps are a bit long but well worth it. Once you've got it working it is easily repeated.
In each tiddler that I want in my PDF, I mark with a specific tag; I used TableOfContents.
In each tiddler that is marked with this tag, I added an order field--to be used to define the order of tiddlers to appear in the PDF.
Ensure your HTML headers are properly defined for the document. I think tiddler titles use <h2>, so properly defining subheadings using <h3><h4> etc will ensure, if you want, a nice auto-generated Table of Contents in your PDF.
If you want each tiddler to start on a new page (in the PDF), we need to add this HTML to the end of each tiddler:
<div style = "display:block; clear:both; page-break-after:always;"></div>
With a completed TiddlyWiki document export the tiddlers to a single HTML file--this will be used to generate a PDF document. To export, go to the AdvancedSearch, select the Filter tab. In the search textbox enter your filter criteria--for me that was:
[tag[TableOfContents]sort[order]]
You'll see, immediately, on-screen a list of the tiddlers the system found based on that criteria. Then click on the Export icon and select Static HTML.
Optionally, but I think it's a great idea, manually create a cover page (in your favorite editor)--this will be a single HTML file to act as the cover page in the PDF document; call it cover.html. More on this later.
Download and install wkhtmltopdf (command-line tool to generate PDF from an HTML file).
https://wkhtmltopdf.org/downloads.html
Learn and get familiar with the wkhtmltopdf command line syntax. There are numerous features here so the command you end up with maybe lengthy. Use wkhtmltopdf /? to view general help, then wkhtmltopdf --extended-help to view details (well worth the read).
Generate a PDF document. At the command prompt navigate to the folder where your TiddlyWiki document is located. Here is a list of my favorite command-line switches. My app is installed in C:\Program Files..., so my command line starts with that...
"c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"
Add this switch for a header on the left:
--header-left "My document title"
For a header on the right:
--header-right "v1.0.0.1"
Font size of header:
--header-font-size 8
Display a line below the header:
--header-line
Spacing between header and content in mm (default 0):
--header-spacing 5
A left-footer ([section] is replaced with the name of the current section:
--footer-left "[section]"
A centered footer:
--footer-center "Page [page] of [topage]"
Footer font size:
--footer-font-size 8
Footer spacing:
--footer-spacing 5
If you want titles to hyperlink (in the PDF) to go back to the TOC:
--enable-toc-back-links
Make sure no background images get printed:
--no-background
I added special styles in the TiddlyWiki document for print media--to hide tags and clean up the spacing. Then I used this switch to ensure print media is used:
--print-media-type
Being in North America I want letter-size pages; I think the default is A4:
-s Letter
IMPORTANT--give the tool access to local files, otherwise your images will be missing in the PDF:
--enable-local-file-access
Use this if you want to have a cover page (see step 6 above):
cover "cover.htm"
And use this if you want a TOC automatically generated. Without a cover page, the TOC will be your first page, so create a cover page:
toc
After the toc identify your exported tiddler HTML file as input to the tool:
tiddlers.html
And, the final argument on the command line is the output PDF file name:
MyDocument.pdf
Export the tid to html.
Then in the terminal, issue:
html2pdf $myTid.html $myTid.pdf
$myTid is only a var and can be any name
:)