Markdown Defines Typography

One of the challenges to producing several kinds of documents (e.g., HTML, DocX, PDF, Dashboard, etc.) from a single source is that the common WYSIWYG editors have you specify the physical appearance of elements.

  • The font, color, and size of Headings.
  • How to format titles and legends for tables and figures.
  • How to number figures and tables.
  • What is the base font.
  • What is the page size.
  • How do I get this image to not jump to the next f*%$ing page!!!

Separation of Content from Display

What Markdown lets you

  • Identify the components of the text that have special meaning, and then

  • Defer decisions about styles, colors, fonts, etc. until render time.

In this presentation, the slide title is actually a level 2 heading and is shown on the slide as a bold and larger font face. However, if I rendered this as a single HTML page, it may be Orange but if it goes to a PowerPoint, I want it to fit into my color them and be Red, bold, and Monospace.

Separation Leads to Simplicity

 

👎 Never

Waste your time working on display characteristics before the actual text of what you are producing is finished.

Your time is just too valuable.

Instead 👍

Waste your time working on the actual content of the work you are doing.

The display will come later (reformatting bibliographies, changing journal formats, etc.)

Separation Deferrs Internal Connections

Separating also allows you to generalize things like:

  • References to figures and table and
  • Bibliographies

What chaos is created by inserting a new figure in between Figure 3 and Figure 4 in your thesis written in Word?

Separation Leads to Dynamic Documents

The use of Markdown mixed with R (or python or julia) means that we can:

  1. Specify a table or figure in code
  2. When rendered the actual figure of table is produced with the data.
  3. Allows dynamic documents/reports to be created
  4. Forms tight connection between the data, analyses, and associated textual descriptions

Separation Leads to In-Text Content

Stop typing analyses and data output directly, have Markdown insert results when rendered.

  • Use R code within the text itself.
  • When the document is rendered, it will execute the code an put in the results into the text parts auto-magically (this is a BFD).
  • Changes to data, analyses, df, test statistics, etc. are all integrated.

Markdown is Text

Finally, since Markdown is just text:

  • Allows the use of GitHub for repositories & collaboration,
  • Never becomes lost because you cannot find a copy of some program that is no longer supported,
  • Is always readable on all platforms at all times.

Mardown is Text

YAML

YAML (Yet Another Markdown Language) is a method of setting meta-data relevant to the parsing and rendering of a markdown document.

  • It must be at the top of the document.

  • It is delimited by three dashes, one set above and one below the content.

  • Can be set for all files in a project (see file _quarto.yml in this repository) to standardize meta data for all instances of a document type (e.g., all PDF’s have this them, all DOCX have a TOC, etc.).

YAML Singleton Grammar

The way that YAML works is a simple key:value setup. For these cases, all items are on a single line, like you did previously to change the output from docx to html by changing:

format: docx

to

format: html

The colon is REQUIRED.

YAML as Compound Stuff

Sometimes we have nested YAML. For example, maybe when I make a PDF I do not want a table of contents but when I create an html document I do. Instead of reformatting and rewriting all of this, I can include both PDF and HTML YAML.

To do this, you use tabs to nest items underneath the general section and add a colon to the end of each line that has some kind of nested object.

format:
  html:
    toc: true
  pdf:
    toc: false

YAML with Several Options

And sometimes, we have a lot of options under a single key in YAML. For example, if we have several authors on a paper, we can include them as itemized entries.

author:
  - name: YOUR NAME
  - name: OTHER PERSON

Your Turn 🫵

Try the following and see how it renders.

  1. Open the quarto html document from before and add an option for the author by inserting author: YOUR NAME HERE into the YAML (n.b., you must replace YOUR NAME HERE with your actual name…)
  2. Add three authors to the paper and render it.
  3. Go check out the quarto documentation on authors and affiliations and make an affiliation for each of the three authors.

 

05:00

Simple Typographic Components

Markdown is a method to typeset text using only keyboard commands.

Plain text is displayed as body styled texts.

What you type is what you get.

Titles, Sections, and Headings

In your word processor, you have Titles, Subtitles, Header 1, Header 2, Header 3, etc.

In Markdown, we indicate these elements by prepending a hashtag to the text.

Titles, Sections, and Headings

The more hashtags, the less prominent the header level.

Simple Typographic Markup

The most common features of text are also “marked them up” using the following conventions.

 

Markdown Result
*italic* italic
**bold** bold
~~strikethrough~~ strikethrough

Itemized & Numeric Lists

External Images

External images can be included as well by including full URL.

![Little Kitty Bro](https://www.flickr.com/photo_download.gne?id=54733336478&secret=78d5afc9a9&size=o)

Little Kitty Bro

Additional figure configurations are described here.

Embedding Video

Embed Code from YouTube  

Embedding Live Pages

 

Code Chunks

Markdown mixes rather nicely with code.

  1. We write code as either chunks between paragraphs of text or as individual elements within the text.
  2. Code is evaluated first and the results are determined. It can be code output, tables, or figures.
  3. Then when the Markdown is converted, the code output can be hidden (or shown) and the results of the code are presented.

Chunks of Code

Code chunks are defined by three backticks (under the tilde on the upper left corner of your keyboard) surrounding the code.

 

```{r}
print(“hello world”)
```

produces the output of the command and presents it in analysis output styling (just like R)

[1] "hello world"

Code Chunks

You can also produce graphics (this makes a histgram from 1000 random numbers from a normal distribution).

```{r}
hist( rnorm(1000) )
```

Mermaids

These were R code, but Quarto can integrate all kinds of code. Here is what we call a Mermaid Diagrams.

 

```{r}
flowchart LR
A[Hard edge] –> B(Round edge)
B –> C{Decision}
C –> D[Result one]
C –> E[Result two]
```

Mermaids

flowchart LR
  A[Hard edge] --> B(Round edge)
  B --> C{Decision}
  C --> D[Result one]
  C --> E[Result two]

Presentations

Presentation Formats (Visual)

Presentation Formats (Source)

Slide Separation

Formatting Individual Slide Content

  • Each slice starts with a H2 (e.g., ## title), which is denoted as its “Slide Title”,
  • Subtitles are H3 (### subtitle),
  • Remaining content is normal markdown.

Customizations

There are a ton of customizations available. I would suggest you look to the official Quarto Reference site:

Questions

 

If you have any questions, please feel free to either post to the Canvas discussion board for the class or drop me an email.

Peter Sellers looking bored