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.
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 letcenteringrelax
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.
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
topruleaddlinespace }
{ addlinespacebottomruleend{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}
链接地址: http://www.djcxy.com/p/76758.html
上一篇: 使用类的宏注释创建或扩展伴随对象