This is what I typically put at the top of my documents in R markdown:
---
title: Title
author: Amar Al-Zubaidi
date: \today
mainfont: Inconsolata Nerd Font
sansfont: Inconsolata Nerd Font
monofont: Inconsolata Nerd Font
fontsize: 11pt
table-use-row-colors: true
bibliography: /home/amarakon/Documents/bibliography.bib
csl: /home/amarakon/Documents/Citations/apa-no-initials.csl
classoption: letterpaper
output:
pdf_document:
keep_tex: true
latex_engine: xelatex
template: eisvogel
number_sections: true
---
I do pretty much the same thing for every document.
In fact, the only thing I change for every document is the title.
I want to know how I can put all of these values in a file (except for the title), and change my compile command to read that file when compiling. This is the command I use to compile:
R -e "rmarkdown::render('file.Rmd')"
My end goal is to only have to put something like this in my Rmarkdown document:
---
title: my-title
---
I answered a similar question not that long ago using this information.
Since I had worked on that question, I only had to clone my last template and update the skeleton to create your template.
You won't have a YAML with just your title. However, all of the elements that you specified you wanted would be pre-written in the RMD file when you open a new file using this template.
You can see this repository at fraupflaume/customYAML2.
To install this template (it's not a package per se; there's no library):
devtools::install_github("fraupflaume/customYAML2")
When you want to start a new RMD script, go to templates -> Custom YAML -> customYAML2.
If you wanted to change this down the road, you can fork or clone that repository and edit it to your heart's content.
BTW:: let me know if you want me to remove the images. (It has your name in them: here and on Github.)
Related
I am using Quarto for my dissertation and wish to change the table of contents line spacing to 1 when rendering to a PDF. I have my line spacing for the rest of the document set to 1.5 using linestretch: 1.5.
I have tried making up commands such as toc-linestretch: 1.5, which has not worked for me. From the basic documentation, I don't see how to change the toc spacing to 1 and keep the rest of the document spacing to 1.5. If anyone knows how to do this within the _quarto.yml file, please let me know!
I have also tried to make a custom toc.text file as a LaTeX/template partial, but so far it's not working. I based my toc.tex file on the defaul template provided in the Quarto source code (scroll to line ~337). My current toc.tex file is:
\usepackage{setspace}
\setstretch{1}
$if(has-frontmatter)$
\mainmatter
$endif$
$body$
I expected \setstretch{1} to work, but this is my first experience with LaTeX, so I wouldn't be surprised if my toc.tex file has issues, but I'm not sure what to try next. Thanks!
The toc.tex file you have provided here doesn't contain the necessary command (\tableofcontents) to generate the table of contents and you don't need to use the template.tex if you just need to modify the toc, you may use just the toc.tex instead.
So you can try to use the following toc.tex file (which I have modified a bit by removing lines for beamer format)
toc.tex
{\setstretch{1} % set the linestrech from here ------------------------
$if(toc)$
$if(toc-title)$
\renewcommand*\contentsname{$toc-title$}
$endif$
$if(colorlinks)$
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}
$endif$
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
$endif$
} % upto here ---------------------------------------------------------
$if(lof)$
\listoffigures
$endif$
$if(lot)$
\listoftables
$endif$
And then put the \usepackage{setspace} under include-in-header yaml key in the _quarto.yml file.
_quarto.yml
project:
type: book
book:
title: "Book"
author: "Jane Doe"
date: "1/4/2023"
chapters:
- index.qmd
- intro.qmd
- summary.qmd
- references.qmd
bibliography: references.bib
format:
pdf:
documentclass: scrreprt
linestretch: 1.5
include-in-header:
text: |
\usepackage{setspace}
template-partials:
- toc.tex
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"])
I am writing a book with bookdown. Unfortunately, I have no clue how to format (e.g. setting font size) ATX-hearder (#, ##, ## etc.). So far, it does not work via pandoc or preamble.tex.
I have tried the following, with regard to this.
Unfortunately, there is an error message :
\usepackage{titlesec} \titleformat{\chapter}[display] {\normalfont\sffamily\huge\bfseries\color{blue}} {\chaptertitlename\ \thechapter}{20pt}{\Huge}
Thanks in advance!
Your best bet here is to add a LaTeX preamble to the document. In here, you can define the required LaTeX packages. Two changes are made to the base template:
We need to add subparagraph: true to make titlesec work with R Markdown, as explained here
# refers to a level one header in pandoc, and therefore you need to make the style changes for section not chapter https://www.sharelatex.com/learn/Sections_and_chapters
Here is a minimal example
---
output:
pdf_document:
includes:
in_header: header.tex
subparagraph: true
---
# Section
## Subsection
The preamble.tex file is saved in the same directory:
\usepackage{titlesec}
\usepackage{color}
\titleformat*{\section}{\LARGE}
\titleformat{\subsection}[display]
{\normalfont\sffamily\huge\bfseries\color{blue}} {\chaptertitlename\ \thechapter}{20pt}{\Huge}
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
:)