fileunderwater
fileunderwater

Reputation: 1125

How to left align a whole table in markdown (pandoc)?

How do you left align an entire table in Markdown/Pandoc? I know about different ways of specifying tables and how alignment of columns are done, but I cannot find a way to shift the table from center aligned to left aligned (have even tryed embedding <div style="float: left>..</div> which didn't work). Do I have to switch to LaTeX to do this? I will export to pdf later on, if that makes a difference.

Upvotes: 17

Views: 11918

Answers (3)

Marc Le Bihan
Marc Le Bihan

Reputation: 3304

I've found this solution here.

a simple \usepackage in header-includes: that looks doing the job itself...

- \usepackage[margins=raggedright]{floatrow} 

I hope it won't have side effects. Currently, on my pandoc generated pdfs, none, but I don't know its boundaries.

  • it has at least one limit: it applies upon every table of your pdf, and not a single one, if it's what you were looking for.

Upvotes: 3

Eli Holmes
Eli Holmes

Reputation: 676

I was not able to get the solutions here to work--in LaTeX. I created a new longtable environment to make tables the way I wanted them. That was easier in the end. Here's an example Rmd file.

---
title: "Custom table"
header-includes:
  - \usepackage{longtable,booktabs}
output: pdf_document
---

\newenvironment{mylong}
    {\begin{longtable}[l]{p{.25in}p{3in}p{3in}}Line & Statements  & Reasons\\
    \toprule\addlinespace }
    { \addlinespace\bottomrule\end{longtable} }

\begin{mylong} 
1& $a+b=a+d$    & Given P10, if $b=d$, then 1 is true\\
2& $a+b=c$ & Given\\
3& $a+d=c$ & Given P9, if 1 and 2 are true, then 3 is true. QED\\
\end{mylong}

Upvotes: 3

fileunderwater
fileunderwater

Reputation: 1125

I now found a solution to this problem at tex.stackexchange.com. Apparently pandoc inserts \centering for every float in the document. This can be cancelled by inserting \let\centering\relax in a custom preample to pandoc (as pandoc argument -H custompreample.tex). The link also describes more detailed ways to for example define different floats for tables and figures.

Upvotes: 6

Related Questions