Skip to content

pandoc tabularize

Benct Philip Jonsson edited this page Jul 6, 2015 · 3 revisions

This is the documentation for pandoc-tabularize.pl.

NAME

pandoc-tabularize.pl - pandoc filter to use tabular instead of longtable in LaTeX

VERSION

0.001

Date: 2015-07-06

SYNOPSIS

pandoc -t latex -F pandoc-tabularize.pl [-M tabularize_all=true] [OPTIONS] FILE_NAME ...

DESCRIPTION

pandoc-tabularize.pl is a pandoc filter to use the tabular environment instead of the longtable package in LaTeX output. This is especially useful if you want to use twocolumn mode, which doesn't work with longtable.

There are two ways to get a tabular environment -- possibly wrapped in a table environment -- instead of a longtable:

  1. Put a key-value pair tabularize_all: true in your metadata block, (or pass -M tabularize_all=true on the commandline).

    This will turn all tables into tabularize environments, and if they have a caption also wrap them in a table environment.

  2. Wrap the table in a <div> with a class tabularize.

    If you also add a class float the tabularize environment will be wrapped in a table* environment and hence become a float.

    If you add a class like pos:t or pos:p there will also be a table* environment, with whatever came after pos: in the class name as the optional argument to that environment.

    Any id on the <div> will also be added as a \label{tab:ID}. This is probably actually unnecessary since pandoc will add a generally much more useful \hyperdef{}{ID}{\label{ID}} above the <div>, but it's there in case you find some use for it

Note that the content of the div should be a normal Pandoc Markdown table (of any type!) with whatever Markdown markup normally works in a table.

Example

In your Markdown document:

---
title: Test of twocolumn table hack filter
classoption: twocolumn
tabularize_all: true
...

<div id=firsttable class=tabularize>

Quia Iusto          Et Quisquam         Est Expedita
------------------  ------------------  -------------------
Facilis Aut         Et Aut              *Veritatis* Eveniet
Blanditiis Sit      Eligendi Provident  Sunt Ducimus

: This should be a non-floating tabularize

</div>

Minus Amet           Pariatur Soluta     Voluptate Consectetur
------------------  ------------------  ----------------------
Eos Possimus        A Quasi             Vel Autem
Est Magni           Assumenda Volupta   Id Laboriosam

: This also, with `tabularize_all: true`

<div class="tabularize float">

-------------------------------------------------------
Quia Ut             Sint Ratione        Voluptas Magnam
------------------  ------------------  ---------------
Blanditiis Enim     Animi Ut            Eaque Eum
Quidem Aut          Et Vitae            Nesciunt Voluptatem

Voluptatem Illo     Iste Cupiditate     Explicabo Vel
Est [Dolorem][]     Consequuntur Eaque  In Impedit
-------------------------------------------------------

: This should be a floating table*

</div>

<div class="tabularize pos:b">

Expedita Ut     Fugit Numquam       Quas Quia
--------------  ------------------  ---------
Nisi Aperiam    Quasi Unde  In Quis
Repellat Tenet  Est Sit Facere Dolore

: this floats to the bottom of the page

</div>

PREREQUISITES

pandoc

perl

CPAN prerequisites

Data::Rmap

JSON::MaybeXS

List::AllUtils~0.09

NEW TO PERL?

Get perl: https://www.perl.org/get.html

How to install modules: http://www.cpan.org/modules/INSTALL.html

AUTHOR

Benct Philip Jonsson <[email protected]>, https://github.com/bpj

COPYRIGHT

Copyright 2015- Benct Philip Jonsson

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.