tags:

views:

157

answers:

4

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?

+1  A: 

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|}
Mica
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.. may be I use bad converter? what converter do you recommend?thanks
ace
If you're not already using docutils, I would try that. There are several converters listed in the manual. I generally like pandoc for a converter, but I don't do much work with rst, so I'm not sure how good the conversion will be.
Mica
A: 

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.. may be I use bad converter? what converter do you recommend? thanks

ace
A: 

The docutils rst2latex writer has some issues with tables: http://docutils.sourceforge.net/docs/dev/todo.html#tables , so maybe your problem is related to that? I think the Sphinx writer is based on rst2latex and might thus have the same issues.

Matti Pastell
A: 

actually the command

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

is needed just before .. list-table::

http://sphinx.pocoo.org/markup/misc.html?highlight=tabularcolumns#dir-tabularcolumns

ace