I am trying to create a document which automatically updates certain values according to an output from a python code. From this python code, it produces a latex table, which looks pretty basic. However, I have to integrate this table with the document template, so that it matches the rest of the pre-written tables in the document.
The document template for tables are provided by for eg:
\begin{table}[H] \centering
\caption{Nominal Skirt Annulus}
\label{tab:nomskirtannulus}
\begin{tabular} {p{2cm}p{3cm}}
\rowcolor{blue}{\textcolor{white}{Skirt Thickness} } & {\textcolor{white}{Nominal Annulus} } \\
10 & 11 \\
\hline
\end{tabular}
\end{table}
In this template, the number of columns and rows are variable.
The python generated latex table looks like:
\begin{table}
\centering
\caption{bleh}
\label{tab:bleh}
\begin{tabular}{ppp}
\toprule
Tolerance & Bottom & Lowest Can Weld \\
\midrule
Annulus nominal & 0.098000 & 0.098000 \\
MP flange ovality & 0.001000 & 0.001000 \\
\bottomrule
\end{tabular}
\end{table}
This table should be formatted according to the template (with row colour, text colour etc) automatically. Is there a way to do this in Latex?
Thanks.
Best Answer
A safe version which I will strongly recommend is the following:
This will require you to rename all the generated
tabular
environments tomytbl
. Maybe there will be some way to ask Python to generatemytbl
instead oftabular
directly. This will keep all the othertabular
s untouched and safe. If you use any package which usestabular
for some purpose, that tabular will also stay safe.If you are absolutely sure that you (and packages you use) are only going to require
tabular
s of this specific type, then the following might be useful.Both will generate:
Edits:
\UseTblrLibrary{booktabs}
command for supportingbooktabs
commands withtblr
.booktabs
-rules to the table-code and change the output-screenshot.