Search code examples
latexpandocquarto

Remove horizontal table lines from markdown tables in quarto document (pdf)


I'm creating a fairly simple pdf-document using quarto. As part of the document I have a table that is generated as markdown table.

The resulting table in the pdf file contains two horizontal lines - one at the top of the table and one at the bottom. Is it possible to remove those lines altogether either by adding some LaTeX-code or by including an option in the YAML to quarto?

Here is some code that shows the problem

---
title: "Test"
format:
  pdf:
    documentclass: article
---


\vspace{-1.5cm}


### My table

\vspace*{-.3cm}

|   |   |
|--------|--------|
| Name     | Number   |
| Alice | 1 |
| Bob | 2   |
| Charles | 3   |

And here is the result:

enter image description here


Solution

  • The LaTeX commands that generate those lines are \toprule and \bottomrule. We can redefine them to disable the line drawing:

    \renewcommand{\toprule}[2]{}
    \renewcommand{\bottomrule}[2]{}
    

    Adding this snippet to an appropriate place in your document, e.g. in the header-includes metadata or at the top of the document text, should give the desired results.