ismayc / reedtemplates

(DEPRECATED - Please don't use this!) A template for creating Reed College senior theses using R and Markdown.
Other
27 stars 12 forks source link

Replace newline with space for readLines abstract #5

Closed wjones127 closed 8 years ago

wjones127 commented 8 years ago

When I tried adding multiline Rmd files for abstract, preface, and other pages, I ended up getting the following error:

Could not parse YAML header: could not find expected ':' "source"

I realized this was because the pasteLines function was adding newlines in the YAML header, which ended up breaking the YAML indentation format. So instead, I propose here to use a space (' ') instead of a newline character (\n). This is less readable in the markdown, but at least it compiles 👌

ismayc commented 8 years ago

Were you able to have multiple paragraphs in the abstract if you made this change? That was the initial reason why I used \n but it appears that functionality was changed in rmarkdown or knitr over the last few months.

wjones127 commented 8 years ago

Oh you are right; this way line breaks do not appear at all. I suppose I should do more testing later to see if there is a way to keep the new line and fix the problem with my YAML headers.

wjones127 commented 8 years ago

This is an unsatisfying workaround, but I have just figured out I can use LaTeX's \newline command to make new lines in these sections while using the space separator. This is what I am using in my thesis for now.

ismayc commented 8 years ago

Did you have to put dollar signs around \newline to get it to work? I did...

wjones127 commented 8 years ago

So I was playing around with it a little more. I don't know why you had to have dollar signs around \newline, but I discovered \\ doesn't work, but \par does (and is more appropriate than \newline). If I figure out anything else I will let you know.

ismayc commented 8 years ago

I think your solution of changing it to ' ' from "\n" and then using \par is the way to go. That appears to be working for me. I'll make the change as soon as I can and add an example to the template for each of the different files: abstract.Rmd, dedication.Rmd, etc. Thanks again!

ismayc commented 8 years ago

I tweaked a few other things as well and made the change to \par. Thanks, @wjones127!