Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert tables in rst to LaTeX

I have some .rst files and I convert them to .tex file using standard sphinx converter.

In some .rst I have tables with special width like:

.. list-table::  
   :widths: 50 50 

The resulting .tex always contains tables like:

\begin{tabulary}{\textwidth}{|L|L|}

So, the column width is lost.

How can I preserve column width when converting rst to latex?


I used comma separator too,

.. list-table::  
   :widths: 50 , 50 
   :header-rows: 1 

* - SETTING 
  - DESCRIPTION
* - Enable 
  - Enables or disables internal tracing.
* - Verbose 
  - Enables or disables extended internal tracing. 

but it doesn't work.. maybe I used a bad converter? What converter do you recommend?

like image 581
ace Avatar asked Apr 07 '10 18:04

ace


2 Answers

actually the command

.. tabularcolumns:: |p{4.5cm}|p{8.5cm}| 

is needed just before .. list-table::

https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-tabularcolumns

like image 162
ace Avatar answered Oct 17 '22 22:10

ace


try:

:widths: 50, 50

with a comma separator.

The output also depends on how your table is written in rst.

I assumed that you were using the standard rst table syntax, not making tables from bulleted lists (as is possible). For more help, try http://docutils.sourceforge.net/docs/ref/rst/directives.html#tables

Also, if the 50, 50 is the column width, your latex code should look like this:

\begin{tabulary}{  1\textwidth}{ | p{0.5} | p{0.5} | }

and:

\begin{tabulary}{total width of table}{| column width| column width|}
like image 39
Mica Avatar answered Oct 17 '22 22:10

Mica