6

Right alignment comes handy for letter addresses. Unfortunately, according to the author John MacFarlane:

The pandoc document model does not allow for alignment other than in tables, so the alignment information is simply ignored.

We can resort to raw LaTeX.

Upon trial and error (and googling) I found that this TeX syntax works as intended:

\rightline{Address 1}
\rightline{Address 2}
\rightline{etc}

Also the LaTeX equivalent does:

\begin{flushright}

Address 1\\
Address 2\\
etc

\end{flushright}

The less invasive syntax, based on the LaTeX command raggedleft, unfortunately does not work:

{\raggedleft
Address 1\\
Address 2\\
etc\\
}

This is because braces are passed verbatim (\{, \}) and not as raw LaTeX.

With reference to centre alignment, I found a user claiming that markdown supports this native (beautiful) syntax:

-> This is center align <-

but I didn't find an editor/converter supporting it.

Indeed my working examples are all against the John Gruber markdown philosophy:

A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.

Can you find a better way?

Particularly is it possible to simply write a Pandoc template to redefine the alignment of a header, say: ###### Right aligned?

Community
  • 1
  • 1
antonio
  • 10,629
  • 13
  • 68
  • 136
  • Instead of using `{\raggedleft ...}`, how about `\begingroup\raggedleft ...\endgroup`? – Werner Nov 03 '13 at 04:31
  • @Werner: Because I am looking for a lighter syntax and yours is more invasive than `\begin{flushright} ... \end{flushright}`. – antonio Nov 03 '13 at 11:39

2 Answers2

11

For those that are looking for a similar question here's how to left align/right align on the same line:

**Some bolded text** **\hfill some right aligned on same line bolded text**

You'll have to imagine the result since I'm not sure how to recreate it on SO.

Jon49
  • 4,444
  • 4
  • 36
  • 73
  • This does not work with Markdown, it will kill a character and does not right align the text line. – Timo Jul 07 '20 at 09:11
  • 1
    Worked ok for me: notice that the `\hfill` is inside the formatting markdown `**\hfill bold**` – Colin Aug 23 '21 at 04:42
4

The best way to handle this is to put the address in a YAML metadata block (supported by pandoc 1.12+), and do the alignment in a custom template. Then your source document will be clean, without raw LaTeX, and you can modify templates to get the desired look in any output format.

Source document could look like this:

---
address:
  | 23 Main St.
  | Somewhere, MT 23434
...

Dear so and so,

Then in your LaTeX template you'd have something like:

\begin{flushright}
$address$
\end{flushright}

If you're writing a letter, though, it would probably be better to write a template using the LaTeX letter class.

John MacFarlane
  • 8,511
  • 39
  • 33