At the end of a survey I've conducted, we give respondents an open ended box to tell us anything we didn't cover in the survey.These comments will often span several pages. I am familiar with the longtable
package for LaTeX and here is the solution I have mocked up:
<<results = tex>>=
cat("\\begin{longtable}{p{14cm}}\n")
cat("\\hline\n")
write.table(toBePrinted, eol = "\\\\\n", col.names = FALSE)
cat("\\hline\n")
cat("\\end{longtable}")
@
While this solution technically works, it doesn't look terribly polished and needs to be improved. I have two related questions:
- Text sanitation tips for Sweave output that is to be treated as
tex
. For example, if someone saysYour survey is awesome & I would take more surveys for $$$ 100% of the time!
the special characters&, $, %
reak havok when processing throughLaTeX
. Is there something more efficient than a list ofgsub
calls to replace the offending characters with something benevolent? - Suggestions for a better way to print these long comments with
Sweave & LaTeX
.