This question comes from combination of two previous questions A and B which worked properly without any problem. But it fails when I combine them.
I have a result file
results/measurements.txt
length1=0.111111111
length2=0.123456789
length3=0.333333333
And I would like to call it in my code as
\paraminput[length2]{results.txt}
It reads the file and extract the result. It works fine except for 0.123456789 is too long and I do not like to touch the result file because it should be updated everytime and I cannot always keep editing it.
So I need another command to perform rounding. So the defined command \round[2]{0.123456789} also works fine. It prints what it should.
The problem is with when I combine them as
\round[2]{\paraminput[length2]{results.txt}}
It does not work and it give an error:
Missing \endcsname inserted. ...2]{\paraminput[length2]{measurements.txt}}
...
LaTeX error: "kernel/file-not-found" File '"results/\endcsname "' not found. For immediate help type H . ...2]{\paraminput[length2]{measurements.txt}}
,
Undefined control sequence. ...2]{\paraminput[length2]{measurements.txt}}
How should I fix this problem?
source.tex
\documentclass{article}
\usepackage{tikz}
\usepackage{xparse} % for paraminput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\round}[2][2]{
\pgfkeys{/pgf/number format/.cd,std,precision=#1}
\pgfmathprintnumber{#2}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
\ior_new:N \ar_param_file
\seq_new:N \g_ar_param_seq
\cs_new:Nn \ar_read_by_line:n {%
\seq_gput_right:Nn \g_ar_param_seq {#1}
}
\tl_new:N \g_paramfile_path_tl
\NewDocumentCommand{\parampath}{m}{%
\tl_gset:Nn \g_paramfile_path_tl {#1}
}
\NewDocumentCommand{\paraminput}{O{default1} m}{%
\seq_gclear:N \g_ar_param_seq
\ior_open:Nn \ar_param_file {\g_paramfile_path_tl #2}
\ior_map_inline:Nn \ar_param_file {\ar_read_by_line:n{##1}}
\ior_close:N \ar_param_file
\seq_map_inline:Nn \g_ar_param_seq {%
\seq_set_split:Nnn \l_tmpa_seq {=} {##1}
\seq_if_in:NxT \l_tmpa_seq {#1} {\seq_item:Nn \l_tmpa_seq {2}\seq_map_break:}
}
}
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\parampath{results/}
\begin{document}
It shows fine: $\paraminput[length2]{measurements.txt}$.
It shows fine: $\round[2]{0.123456789}$.
But this one shows error: $\round[2]{\paraminput[length2]{measurements.txt}}$.
\end{document}

\prop_set_from_keyval:NVand then\prop_set_eq:cNrather than just having:cVin the first command? – Manuel May 24 '18 at 09:51LaTeX error: "kernel/command-not-defined" ! ! Control sequence \prop_set_from_keyval:Nn undefined.– ar2015 May 24 '18 at 12:43\DeclareExpandableDocumentCommandinstead of\NewExpandableDocumentCommandfixes some of the errors but not all. Upgrading will be a trouble and the target journal will face with an error. I cannot ask them to update their latex version. Are these features replaceable with the older versions? – ar2015 May 24 '18 at 13:00pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) kpathsea version 6.2.1– ar2015 May 24 '18 at 13:02;-)– egreg May 24 '18 at 16:15