Skip to content

Instantly share code, notes, and snippets.

@agoldst
Created November 24, 2013 00:20
Show Gist options
  • Save agoldst/7621786 to your computer and use it in GitHub Desktop.
Save agoldst/7621786 to your computer and use it in GitHub Desktop.
Markdown source for a handout on markdown, HTML, and LaTeX, typesettable with pandoc + xelatex.

% DH@RU Workshop: Empowerment Part II % Andrew Goldstone (andrew.goldstone@rutgers.edu) % November 20, 2013

Markdown

Text conventions

*emphasis* or _emphasis_; **strong emphasis**

emphasis or emphasis; strong emphasis

extra white  space     doesn't 
   matter

extra white space doesn't matter

Where white space does matter

Paragraphs are broken by blank lines.

This is the start of a new paragraph.
But this isn't.

Paragraphs are broken by blank lines.

This is the start of a new paragraph. But this isn't.

Extra spaces at the end of a line␣␣
make a "hard linebreak."

Extra spaces at the end of a line
make a "hard linebreak."

    Four spaces at the start of a line mark "code."
    This text is meant literally: *not styled*.

Four spaces at the start of a line mark "code."
This text is meant literally: *not styled*.

Structure

# Heading
## Subheading
### Subsubheading

> A block quotation, which can be
> spread over multiple lines if you like.

1. An enumerated list.
2. Another thing.
1. A third thing.

- An "unordered" list.
- Must you bullet point?
  1. An enumerated list.
  2. Another thing.
  3. A third thing.
  • An "unordered" list.
  • Must you bullet point?

Hypertext

Links are written in two parts, the actual URL and the text of the link:

[a link to my home page](http://andrewgoldstone.com)

More

andrewgoldstone.com/md/ for my notes;
daringfireball.net/projects/markdown/basics for an introduction by Markdown's inventor;
johnmacfarlane.net/pandoc/README.html#pandocs-markdown for pandoc's extended markdown
(also available through the command man pandoc_markdown).

HTML

Text conventions

Most annotations are tag pairs: <xyz>...</xyz>.

<em>Annotation for emphasis</em>
<strong>Annotation for strong emphasis</strong> 
Extra white  space    still     doesn't         matter

Structure

HTML tells you about structure: every paragraph is tagged.

<p>I am a paragraph.</p> <p>I am a second paragraph, even if
I do start on the same line.</p>
<p>I am a paragraph using the self-closing <br>
tag to break a line.</p>

HTML is strictly hierarchical.

<!DOCTYPE html>
<html>
    <head>
    ...
    </head>
    <body>
        <p>...</p>
        <p>...
            <em>...</em>
        ...</p>
    </body>
</html>

More tags

<h1>Top-level heading</h1>
<h2>Subheading</h2>
<h3>Etc.</h3>

The hierarchy means that block quotes and lists require more annotations:

<blockquote>
    <p>A single-paragraph block.</p>
</blockquote>

<blockquote>
    <p>A single-paragraph block.</p>
    <p>A two-paragraph block.</p>
</blockquote>

<ol>
    <li>First</li>
    <li>Second</li>
    <li>And last.</li>
</ol>

<ul>
    <li>First</li>
    <li>Second</li>
    <li>And last.</li>
</ul>

<div>
    <p>A purely abstract block-level division.</p>
    <p>With several paragraphs.</p>
</div>

<p>A paragraph with an abstract <span>inline element</span>.</p>

Links and attributes

After the <xyz of an opening tag (and inside the < >), HTML allows attributes of the form name="value". A common abstract attribute is a unique id for an element:

<p id="par1">I am a paragraph.<p>

More useful is the href attribute of the "anchor" tag <a>.

<a href="http://andrewgoldstone.com">this is a link to my home page</a>

You can also specify an href to an id using #:

<a href="#par1">I refer back to the element
with id <code>par1</code> on this page.</a>

Heads and bodies

All of the displayed elements of the document live within the <body>...</body> tags. Most of the metadata about that displayed content lives in the <head>:

<head>
<title>The title of the page</title>
<meta charset="utf-8">
</head>

(The <!DOCTYPE> declaration lives outside the <html> element itself, however.)

More

www.htmldog.com/guides/html: puckish and good introductions to HTML and CSS.
developer.mozilla.org: lots of material, including introductions to HTML, CSS, and every other web technology under the sun. Uneven.

\newpage

\LaTeX

\TeX\ is the underlying typesetting language by Donald Knuth, and \LaTeX\ is the system built on top of it by Leslie Lamport and many others.

Document structure

  1. Class declaration \documentclass[12pt]{article} (in most cases).
  2. Preamble (formatting commands, use supplied template)
  3. \begin{document}
  4. Actual document content
  5. \end{document}

Text markup

Extra white  space     doesn't 
    matter.

Extra white space doesn't matter.

One or more blank lines in the source makes a paragraph break.

If you wish to insert a linebreak of your own, use a double backslash \\.

``Double quotes'' and `single';
the apostrophe's easy;
and dashes---the em dash---and the en dash (for numbers, as in 1990--2000).
An ellipsis\ldots gets its own command (notice the space after disappears).

``Double quotes'' and `single'; the apostrophe's easy; and dashes---the em dash---and the en dash (for numbers, as in 1990--2000). An ellipsis\ldots gets its own command (notice the space after disappears).

Here is an example of \emph{emphasis} and of
\emph{emphasis with a \emph{further} emphasis within it}.

Here is an example of \emph{emphasis} and of \emph{emphasis with a \emph{further} emphasis within it}.

And the favorite humanist command\footnote{Note text. Numbers are automatic.}:

\footnote{Note text. Numbers are automatic.}

Sectioning

\section{Section name}, \subsection{...}, \subsubsection{...}

Environments

Documents are further structured by environments, which set text differently from ordinary paragraphs.

Block quotations:

\begin{quote}
A blockquote.
\end{quote}

\begin{quote} A blockquote. \end{quote}

Verse:

    \begin{verse}
    The poem must resist the intelligence \\
    Almost successfully. Illustration:
    
    A brune figure in winter evening resists \\
    Identity.
    \end{verse}

\begin{verse} The poem must resist the intelligence \ Almost successfully. Illustration:

A brune figure in winter evening resists \ Identity. \end{verse}

More

andrewgoldstone.com/tex has pointers to further reading.
tug.org, the \TeX\ Users' Group, is the clearinghouse for things \TeX.
LyX, from lyx.org, which I do not use, provides a graphical ("What You See Is What You Mean") way to edit LaTeX documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment