In the end I decided to use Sweave.
I.e., I have an Rnw file with tex and R code chunks which acts as a pre-processor for a LaTeX document.
I have a csv file which stores the hypotheses with one hypothesis per row:
hypotheses <- read.csv("hypotheses.csv")
The following R function outputs the latex for the hypothesis environment:
outputHypothesis <- function(label, data = hypotheses) {
result <- c("\\begin{hypothesis}",
paste("\\label{", label, "}"),
data[data$label==label, "text"],
"\\end{hypothesis}")
cat(result, sep="\n")
}
Then the Rnw file has an R code chunk which inserts the tex:
<<results=tex>>=
outputHypothesis("H1XcausesY")
@
I still have to finalise the next step of actually creating the table of hypotheses, but I think I'll implement it as an R code chunk in Sweave.
One thing I've already done is use the database to display a table in the discussion section that uses the database of hypotheses as the source and shows (based on the database) whether the hypotheses were supported in a each of a set of studies:
\begin{landscape}
\singlespacing
\begin{longtable}[p]{p{2cm}p{10cm}p{2.5cm}p{2.5cm}p{2.5cm}}
\caption{Summary of Support for Hypotheses}
\label{discussionhypotheses}\\
\toprule
Number & Hypothesis & Study 1 & Study 2 & Study 3\\
\midrule
\endfirsthead
\toprule
Number & Hypothesis & Study 1 & Study 2 & Study 3\\
\midrule
\endhead
\multicolumn{5}{r}{\emph{Table continues on next page}} \\
\endfoot
\bottomrule
\endlastfoot
<<hypothesis_table, results=tex>>=
discussionHypotheses <- paste("\\ref{", hypotheses$label, "}",
"& ", hypotheses$text,
" & ", hypotheses$support_study1,
" & ", hypotheses$support_study2,
" & ", hypotheses$support_study3,
"\\\\")
cat(discussionHypotheses, sep ="\n")
@
\end{longtable}
\end{landscape}