-
I'm using a scripted process to generate reports on financial data that includes a lot of tables. Mostly this is done be generating CSV files and then a Markdown file that includes them. There are a couple different table layouts, but each layout is used several times. The code I'm using generates consistent Markdown, but the output is entirely irregular and I can't figure out why. All tables have meta data that specifies the table width and column widths. As the code runs a for look to generate tables from a series of CSV data sets I would expect all the tables to render the same. They don't. For example check out these results. First lets inspect the generated Markdown source file. I'm $ cat status.md | grep width: | head -n18
table-width: 1.0
width: [0.2, 0.8]
table-width: 1.0
width: [0.2, 0.2, 0.2, 0.4]
table-width: 1.0
width: [0.2, 0.8]
table-width: 1.0
table-width: 1.0
width: [0.06, 0.64, 0.1, 0.2]
table-width: 1.0 Note that of the first 10 tables in the source, all of them should be 100% width. Table 4 does not specify column widths and leaves it to auto-align. Tables 1 & 3 should both have the same column widths, as should 5 & 6 and 7 & 8 & 9. This is not what happens. When rendering to PDF via LaTeX the tables look like this on the page: Note that neither of the tables are drawn full width. The same happens for the other sets. Tables 6 and 8 are both actually 100%, but 5 and 7 which should have similar layouts are both somewhat less. Outputting to HTML tells a similar story. Looking at the table definitions of the first 10 tables output: $ cat status.html | grep '<table' | head -n10
<table style="width:76%;">
<table>
<table style="width:50%;">
<table>
<table style="width:94%;">
<table>
<table style="width:100%;">
<table style="width:100%;">
<table>
<table style="width:100%;"> A few of these tables are left to their own means for width. A few of them have 100% definitions. The others have bizarre specific numbers that come out of nowhere. Note the 76% and 50% widths for tables 1 and 3 respectively correspond to what the LaTeX output did as well. Here is the full source code at the start of table 1 and 3 for comparison and to show there isn't something else funky going on in the source. Only the CSV format data is being obscured here: How do I end these shenanigans and just get full width tables all the time? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As an experiment instead of going directly to PDF I had Pandoc write a standalone LaTeX format output. The code starting table 1 looks like this: \begin{longtable}[]{@{}rl@{}}
\toprule
\begin{minipage}[b]{0.20\columnwidth}\raggedleft
balance\strut
\end{minipage} & \begin{minipage}[b]{0.52\columnwidth}\raggedright
account\strut
\end{minipage}\tabularnewline
\midrule
\endhead The first column being \begin{longtable}[]{@{}rl@{}}
\toprule
\begin{minipage}[b]{0.18\columnwidth}\raggedleft
balance\strut
\end{minipage} & \begin{minipage}[b]{0.29\columnwidth}\raggedright
account\strut
\end{minipage}\tabularnewline
\midrule
\endhead |
Beta Was this translation helpful? Give feedback.
-
This seems to be a side effect of my workaround for #42. Because I can't both include LaTeX code in the document header and use Pantable I was invoking Pandoc twice, once to render the CSV tables to Markdown and a second time to render the final outputs. Since Markdown doesn't have any comprehension of table widths that information was being lost. |
Beta Was this translation helpful? Give feedback.
This seems to be a side effect of my workaround for #42. Because I can't both include LaTeX code in the document header and use Pantable I was invoking Pandoc twice, once to render the CSV tables to Markdown and a second time to render the final outputs. Since Markdown doesn't have any comprehension of table widths that information was being lost.