
Estoy intentando utilizar la respuesta sugerida para pasar argumentos a un documento LaTeX, publicadoaquícomo solución #Tres.
Paso el argumento de la siguiente manera en mi símbolo del sistema de Windows:
C:\Users\afp\projects>pdflatex "\def\InputFilename{sample}\input{myLaTeXDoc.tex}"
En caso de que no se proporcione el argumento, me gustaría tener un archivo predeterminado para procesar. Sin embargo, el compilador todavía se queja Undefined control sequence. \begin{filecontents*}{\FILENAME.csv}
. no puedo ni
- pasar el argumento en el símbolo del sistema ni
- generar un archivo csv predeterminado.
¿Alguien podría ayudarme con eso?
\documentclass[tikz, border=0mm]{standalone}
\usepackage{array}
\usepackage{readarray}
\readarraysepchar{,}
\usepackage{filecontents}
% If the argument is provided at the Windows command prompt, define \FILENAME as the input argument
% otherwise define \FILENAME as a default comma-separated file to process.
\ifdefined\InputFilename
\def\FILENAME{\InputFilename}
\else
\begin{filecontents*}{\FILENAME.csv}
1,2,3
4,5,6
7,8,9
10,11,12
\end{filecontents*}
\fi
\begin{document}
\wlog{filename is \FILENAME.csv}
\readdef{\FILENAME.csv}\namedata
\readarray\namedata\mydata[-,\ncols]
\wlog{\FILENAME.csv has \nrows rows and \ncols columns.}
\end{document}
Respuesta1
No defines \FILENAME
en el caso que filecontents*
se usa, presumiblemente quieres algo como esto que lo defina como\jobname
\documentclass[tikz, border=0mm]{standalone}
\usepackage{array}
\usepackage{readarray}
\readarraysepchar{,}
\usepackage{filecontents}
% If the argument is provided at the Windows command prompt use it
% otherwise create a default comma-separated file to process.
\ifdefined\InputFilename
\def\FILENAME{\InputFilename}
\else
\def\FILENAME{\jobname}
\begin{filecontents*}{\FILENAME.csv}
1,2,3
4,5,6
7,8,9
10,11,12
\end{filecontents*}
\fi
\begin{document}
\wlog{filename is \FILENAME.csv}
\readdef{\FILENAME.csv}\namedata
\readarray\namedata\mydata[-,\ncols]
\wlog{\FILENAME.csv has \nrows rows and \ncols columns.}
\end{document}
Respuesta2
La respuesta no me funcionó, tuve que cambiar algo:
\documentclass[tikz, border=0mm]{standalone}
\usepackage{array}
\usepackage{readarray}
\readarraysepchar{,}
% If the argument is provided at the Windows command prompt, define \FILENAME as the input argument
% otherwise define \FILENAME as a default comma-separated file to process.
\ifdefined\InputFilename
\def\FILENAME{\InputFilename}
\else
\def\FILENAME{\jobname.csv}
\begin{filecontents*}{\FILENAME}
1,2,3
4,5,6
7,8,9
10,11,12
\end{filecontents*}
\fi
\begin{document}
Filename is \FILENAME
\readdef{\FILENAME}\namedata
\readarray\namedata\mydata[-,\ncols]
\FILENAME has \nrows rows and \ncols columns.
\end{document}
Obtuve el PDF creado:
El nombre del archivo es Tabela.csv Tabela.csv tiene 301 filas y 4 columnas.