there are two ways to do what you seek. one is using sweave, the other is using an R package called brew which overcomes sweave's limitations of looping over a global variable. i am providing both code chunks.
The Sweave Code Chunk
\begin{document}
<<echo = F, results = tex>>=
figdir = paste(getwd(), 'fig', sep = '/')
fignames = read.csv('fignames.csv');
for (i in seq_along(fignames)) {
filename = file.path(figdir, i)
cat("\\pagebreak");
cat("\\section{", i, "}", sep = "");
cat("\\begin{figure}[htbp]");
cat("\\caption*{MyCaption", i, "}", sep = "");
cat("\\includegraphics[width = 0.5\\textwidth]{", filename, "}", sep = "");
cat("\\end{figure}");
}
@
\end{document}
The Brew Code Chunk
\begin{document}
<% figdir = paste(getwd(), 'fig', sep = '/') %>
<% fignames = read.csv('fignames.csv');
<% for (i in seq_along(fignames)) { -%>
\pagebreak
<% filename = file.path(figdir, i) %>
<%= cat("\section{", i, "}", sep = "") %>
\begin{figure}[htbp]
\caption*{MyCaption}
<%= cat("\\includegraphics[width = 0.5\\textwidth]{filename}")
\end{figure}
<% } -%>
\end{document}
you can check out the link to brew on how to use it from R
EDIT: this would produce a single file with all the output.
Simply change align argument to b
(bottom) for second block of subfigures:
\begin{subfigure}[b]{.78\linewidth}
\documentclass[]{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}
%opening
\title{}
\author{}
\begin{document}
\begin{figure}[ht]
\begin{subfigure}[t]{.2\linewidth}
\includegraphics[width=\linewidth, height=4\linewidth]{example-image-a}
\caption{TBA}
\end{subfigure}\hfill%
\begin{subfigure}[b]{.78\linewidth}
\begin{subfigure}[t]{.5\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{TBD}
\end{subfigure}\hfill%
\begin{subfigure}[t]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{TBD}
\end{subfigure}\hfill%
\begin{subfigure}[t]{.5\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{TBD}
\end{subfigure}\hfill%
\begin{subfigure}[t]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{TBD}
\end{subfigure}
\end{subfigure}
\end{figure}
\begin{figure}[ht]
\begin{subfigure}[t]{.2\linewidth}
\includegraphics[width=\linewidth, height=4\linewidth]{example-image-a}
\caption{TBA}
\end{subfigure}\hfill%
\begin{subfigure}[b]{.78\linewidth}
\begin{subfigure}[t]{.9\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{TBD}
\end{subfigure}\hfill%
\begin{subfigure}[t]{.9\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{TBD}
\end{subfigure}\hfill%
\end{subfigure}
\end{figure}
\end{document}
Best Answer
This seems like a bit of a strange request- are you sure you don't want to have
LaTeX
generate the figure numbers for you?If you really do want to do this, then here's one way- note that
\newenvironment
to\newcommand
[,]
which means something different from what you intended\setcounter
to change the figure number to what you wantHere's a complete MWE
Perhaps you might have wanted
to be used as, for example