1

I ran into a strange problem when trying to use a selfmade function, which inserts strings from a dataframe in a specific format, based on their location in the text, in a document with several child docs. The generation of the PDF-document always stops with a LaTeX error code 1, after using the name of a german institution with umlauts in my df of strings. No encoding workaround (e.g. \"u, ü) solves the problem.

The setup: RStudio (1.1.442) with rmarkdown (1.9) and papaja (0.1.0) on Windows 10 (1803). Function is defined in the main document, but called, during the knitting, in a child document.

I've already fiddled with the LaTeX-templates encoding/language settings to no success. Umlauts in the main document work as expected, so I am pretty sure there is something wrong with the knitting of the child documents.

Note: I've already solved this for myself (see answers). However, I suppose this is a problem with functions and child documents, rather than the papaja package, so it might be helpful in similar cases. Maybe somebody else can say more about this issue or there is some more reliable way to prevent this?

Jan Alleman
  • 111
  • 1
  • 6

1 Answers1

2

Ultimately, I was able to solve this using BOTH methods described by Georgery and Dirk Eddelbuettel in this question.

In short:

  1. Check the encoding of all documents involved and set them to UTF-8 if necessary
  2. Change umlauts in strings that are printed by your function to the html ampersand notation.

I discovered that the child document had the wrong encoding, but changing it to UTF-8 only solved the issue for the document itself. When the function printed a string from the main to the child, LaTeX would still throw an error. Multiple attempts to knit also didn't work. After additionally exchanging the 'ü' for ü everything went fine.

I don't know what's going on behind the scenes, but I assume that the encoding is messed up somehow when the string is placed at the intended location in the child document.

Jan Alleman
  • 111
  • 1
  • 6
  • Hi Jan, it's possible that this is a bug in `papaja`. Would you be willing to send me a minimal reproducible example? – crsh Aug 01 '18 at 11:28
  • 1
    Hi @crsh, thanks for your comment and the great papaja package. While I tried to make a minimal example for you, I noticed that the issue seems to be gone with a newer version of rmarkdown (1.10). In the meantime I also updated other packages (tidyverse) and R itself, which I did not suspect to interfere at the LaTeX level. The only package I did not upgrade is papaja, so I guess everything is fine on your side and the problem is fixed for everybody now. – Jan Alleman Aug 02 '18 at 12:52