I am trying to write a bash script that gives a tex output for latex beamer. To do so I need to add multiple cat << EOF
(or something similar) after one another. First one should be the first page of the presentation so it comes before the loop. Then there are two nested loops to give multiple pages of the presentation. Finally there are some lines to conclude the latex structure such as \end{document} etc. First page and the last lines are not that crucial but writing the main pages of the slides with loops is crucial to me. But it always chooses the last element of the loops.
Here is a short version my attempt. In the original version, the arrays have more elements than those.
#!/bin/bash
declare -a arrReg=(CR1 CR2)
declare -a arrVar=(pt_el pt_mu)
declare -a arrVarTitle=("electron $p_T$" "muon $p_T$")
laTeXfile=slides.tex
cat > ${laTeXfile}<<EOF
\documentclass{beamer}
\usepackage{graphicx}
\usepackage[font=small,labelfont=bf]{caption}
\begin{document}
%TITLE PAGE
<<text here>>
EOF
for i in "${arrReg[@]}"
do
cnt=0
for j in "${arrVar[@]}"
do
#var=${j}
varTitle=${arrVarTitle[cnt]}
cat >${laTeXfile} <<EOF
%---------------SLIDE
\begin{frame}
<<text here>>
\frametitle{${i}}
\framesubtitle{${varTitle}}
\begin{columns}
<<text here>>
\end{columns}
\end{frame}
EOF
(( cnt++ ))
done
done
cat > ${laTeXfile}<<EOF
\end{document}
EOF
Thank you.