# Padding a number doesn't work when transferring to LaTeX

I have some numbers which I calculate via some previous code. The calculation works fine. However since I want to compare it with experimental data I only need the numbers to a certain number of significant figures.

As an example I have a tuple of numbers:

l = {0.5567857946, 0.55670214585}


I then round this to 5 s.f using SetPrecision[l, 5] which when I print it I obtain {0.55679, 0.55670} which is good, but when I export it to LaTeX and compile it, it is displayed as 0.55679 0.5567. This is not what I want. The following code is an example of what I use to export to LaTeX.

expdat = {
{"\\begin{tabular}{|c|cc|}"},
{"\\hline"},
{"Output", "&", "$Heading1$", "&", "$Heading2$", "\\\\"},
{"\\hline"},
{"$l$", "&", l[[1 ]], "&", l[[2]], "\\\\"},
{"\\hline"},
{"\\end{tabular}"}
};

Export["data.tex", expdat, "Table"]


This results in the desired LaTeX code which I can input into my document using:

\FloatBarrier
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.4}
\setlength{\tabcolsep}{0.5em}
\input{data}
\caption{MyCaption}
\end{table}
\FloatBarrier


Everything comes out fine except I lose the zeroes on the end of my numbers. The LaTeX code itself does not have the zeroes, so the problem lies somewhere within Mathematica/the transfer to LaTeX.

I have tried the following in Mathematica.

PaddedForm[SetPrecision[l, 5], {5, 5}] but this results in the LaTeX displaying where the first l value should be displaying as a pair of numbers except they are the values of l to arbitrary length. Where the second l value should be is displayed as "5,5". If I change the Mathematica code to

expdat = {
{"\\begin{tabular}{|c|cc|}"},
{"\\hline"},
{"Output", "&", "$Heading1$", "&", "$Heading2$", "\\\\"},
{"\\hline"},
{"$l$", "&", l[[1 ,1]], "&", l[[1, 2]], "\\\\"},
{"\\hline"},
{"\\end{tabular}"}
};

Export["data.tex", expdat, "Table"]


Then I get the same as I did before using PaddedForm.

I have done similar with NumberForm[SetPrecision[l, 5], {5, 5}] but I get the exact same problem.

Does anybody have any ideas? Thanks.

It's not clear to me what you exactly tried. Also, your question hinges on how Export handles numbers, and doesn't really have anything to do with LaTeX. I think the problem is that you need to Map or Thread your PaddedForm over your list:

l = Thread[NumberForm[{0.5567857946, 0.55670214585}, {5, 5}], List, 1]


Note I used NumberForm instead of PaddedForm. Then:

expdat = {
{"\\begin{tabular}{|c|cc|}"},
{"\\hline"},
{"Output","&","$Heading1$","&","$Heading2$","\\\\"},
{"\\hline"},{"$l$","&",l[[1]],"&",l[[2]],"\\\\"},
{"\\hline"},{"\\end{tabular}"}
};
ExportString[expdat, "Table"]

"\begin{tabular}{|c|cc|}
\hline
Output	&	$Heading1$	&	$Heading2$	\\
\hline
$l$	&	0.55679	&	0.55670	\\
\hline
\end{tabular}"


I used ExportString so that you can see what the file would look like.