提问人:mrq 提问时间:10/24/2018 最后编辑:mrq 更新时间:10/24/2018 访问量:334
使用 cat EOF 和循环 [duplicate] 编写 tex 文件
Writing a tex file with cat EOF and loops [duplicate]
问:
这个问题在这里已经有答案了:
Bash 中单引号和双引号的区别 (7 个答案)
通过 shell 脚本在字符串中转义美元符号 (6 个答案)
如何将输出附加到文本文件的末尾 (13 个答案)
5年前关闭。
我正在尝试编写一个 bash 脚本,该脚本为 latex beamer 提供 tex 输出。为此,我需要在彼此之后添加多个(或类似的东西)。第一个应该是演示文稿的第一页,因此它位于循环之前。然后有两个嵌套循环来提供演示文稿的多个页面。最后,还有一些行可以总结乳胶结构,例如 \end{document} 等。第一页和最后一行并不那么重要,但用循环编写幻灯片的主页对我来说至关重要。但它总是选择循环的最后一个元素。cat << EOF
这是我尝试的简短版本。在原始版本中,数组包含的元素多于这些元素。
#!/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
谢谢。
答: 暂无答案
评论
>>
>
cat >${laTeXfile}