8

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?

2
  • Instead of using {\raggedleft ...}, how about \begingroup\raggedleft ...\endgroup? Commented Nov 3, 2013 at 4:31
  • @Werner: Because I am looking for a lighter syntax and yours is more invasive than \begin{flushright} ... \end{flushright}. Commented Nov 3, 2013 at 11:39

2 Answers 2

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This does not work with Markdown, it will kill a character and does not right align the text line.
Worked ok for me: notice that the \hfill is inside the formatting markdown **\hfill bold**
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.

2 Comments

how do you compile with pandoc to make your suggestion work?
See the manual under --template and the section on templates.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.