Skip to content

liao961120/insertTables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

title linkReferences tblPrefix links-as-notes header-includes
Pandoc Filter to Insert Arbitrary Complex Tables
true
Table
true
\usepackage{multirow} \usepackage[normalem]{ulem} \pdfstringdefDisableCommands{\renewcommand{\sout}{}}

Outputs: Web Page / LaTeX / PDF / Overleaf

Dependencies

Make sure you have Pandoc and pandoc-crossref installed (callable from cmd).

Usage

Write your complex tables in HTML in tables.html and in LaTeX in tables.tex. https://tablesgenerator.com is a good resource for constructing complex tables. To insert tables into the output HTML/LaTeX document, use the syntax <COMMENT> tbl:table-id <COMMENT> to mark the beginning and <COMMENT> END <COMMENT> to mark the end of a table definition in tables.html and tables.tex. <COMMENT> corresponds to % in LaTeX and <!-- and --> in HTML. tbl:table-id is the identifier of the table used for cross-referencing in the markdown source. Refer to pandoc-crossref for details of cross referencing tables.

To compile the documents, apply the filter custom-table.py AFTER pandoc-crossref in the command line.

pandoc -F pandoc-crossref --lua-filter insertTables.lua README.md -o README.tex
pandoc -F pandoc-crossref --lua-filter insertTables.lua README.md -o README.html

Example

Placeholder
Table

Table: This is a complex table, written in tables.tex and tables.html. {#tbl:custom-table}

See @tbl:custom-table.

Column A Column B
A1 B1
A2 B2

Table: This is a normal table written in markdown, which will not be replaced. {#tbl:normal-table}

Custom Caption Positions

By default, insertTables.lua looks for the string \begin{table}[] and inserts the caption before it. In circumstances where \begin{table}[] is not present in the table's code, this filter will fail. To deal with these cases, you have to tell insertTables.lua where to insert the caption by placing the anchor %caption% in your table's code. This may also be useful when you want to place the caption below the table body. This can be achieved by placing the anchor %caption% after the tabular environment:

\begin{table}[!htb]
    \centering
    \begin{tabular}{lllll}
        \hline
        \textbf{} & \multicolumn{4}{l}{Column Span} \\ \hline
        \multirow{2}{*}{Row Span} & a & b & d & f \\
         & c & d & e & g \\ \hline
        \end{tabular}
    %caption%
\end{table}

which results in @tbl:custom-caption-position (this could only be seen in tex or PDF output).

Placeholder
Table

Table: For LaTeX tables, you can define the position of the caption with the string %caption% in tables.tex. {#tbl:custom-caption-position}

About

Pandoc Lua filter to insert arbitrary complex tables in LaTeX/HTML

Topics

Resources

Stars

Watchers

Forks

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy