I have an issue when trying to use variables in a command (\ResearchModule). I read up to 8 lines from a text file and have them set to elements of an array (using code thanks to egreg!), with \ResearchModule checking to see if they are empty and properly format them. However, \ResearchModule doesn't like that I only provide the variable names and not actual values the arguments.
I've tried a few different iterations with \def, \edef, \expandafter, etc but can't get it to work properly.
Thanks for the help!
\documentclass[10pt]{article}
\usepackage{fancyhdr}
\usepackage[a4paper]{geometry}
\usepackage{tabularx}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\oddsidemargin}{-2cm}
\addtolength{\evensidemargin}{-2cm}
\addtolength{\textwidth}{4cm}
\addtolength{\topmargin}{-2cm}
\addtolength{\textheight}{4cm}
\raggedbottom
\raggedright
\setlength{\tabcolsep}{0cm}
\newcommand{\dates}{3cm}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\newcommand{\AddLine}[1]{
\ifthenelse{\isempty{#1}}{}{\tabitem #1}
\hangindent=0.2cm
\par
}
\newcommand{\ResearchModule}[8]{
\begin{tabularx}{\textwidth}[t]{p{\dates}X}
#1 & \textbf{#2} \\
& \textit{#3} \\
\end{tabularx}
\hspace*{3cm}
\begin{minipage}{.835\textwidth}
\begin{flushleft}
\AddLine{#4}
\AddLine{#5}
\AddLine{#6}
\AddLine{#7}
\AddLine{#8}
\end{flushleft}
\end{minipage}%
}
\ExplSyntaxOn
\ior_new:N \g_hringriin_file_stream
\NewDocumentCommand{\ReadFile}{mm}
{\hringriin_read_file:nn{#1}{#2}
\cs_new:Npn#1##1
{\str_if_eq:nnTF{##1}{*}
{\seq_count:c{g_hringriin_file_\cs_to_str:N#1_seq}}
{\seq_item:cn{g_hringriin_file_\cs_to_str:N#1_seq}{##1}}
}
}
\cs_new_protected:Nn\hringriin_read_file:nn
{\ior_open:Nn \g_hringriin_file_stream{#2}
\seq_gclear_new:c{g_hringriin_file_\cs_to_str:N#1_seq}
\ior_map_inline:Nn\g_hringriin_file_stream{
\seq_gput_right:cx
{g_hringriin_file_\cs_to_str:N#1_seq}
{\tl_trim_spaces:n{##1}}
}
\ior_close:N\g_hringriin_file_stream
}
\ExplSyntaxOff
\begin{document}
\ReadFile{\myarray}{/file.txt}
\ResearchModule
{\myarray{1}}
{\myarray{2}}
{\myarray{3}}
{\myarray{4}}
{\myarray{5}}
{\myarray{6}}
{\myarray{7}}
{\myarray{8}}
\end{document}
file.txt
? Right now, we can't compile your document to reproduce the issue you're facing because we'll get an error due to the missing file./file.txt
should befile.txt
unless the file really is at the root of your filesystem. and please supply a small test version of that so that people can run your example and see the problem. In general I wouldn't use\ifthenelse
(even though it has my name on it) especially as you are using expl3 which already has better tests for arguments just being white space or being empty