conig / revise

R package for writing revise and resubmits

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quote boxes spanning more than one page overloads tex capacity

pdparker opened this issue · comments

I think there might be issues with the use of agrep for pulling large sections from a paper. When a span tag covers lots of text I am getting an out of memory error. Might be good to issue a warning to turn pdf=FALSE in read_manuscript to solve?

@pdparker Yeah looks like you can overload regex matching with bigger strings.
I have put in a fix so strings that exceed 2000 chars are subset to the first and last 1000 characters. We now just match those chunks to get the start and end page. Should be fixed in the latest version.

This should likely be a different issues BUT if the text you are pulling from the manuscript it too long it leads to:

! TeX capacity exceeded, sorry [input stack size=5000]. <to be read again> { l.343 \end{quote}

I have done a heap of debugging on this but cannot quite fix it.

If you go into the tex file and remove the quote tags it works fine.

More investigation. It happens when the text in the box would break across a page. ie. is too large to fit on a single page.

Could be fixed by replacing the framed package with \usepackage{mdframed} and intext use \begin{mdframed} and \end{mdframed} rather than \begin{quote} and \end{quote}. Works in overleaf at least.

This would mean adding our own version of papaja:revision_letter_pdf

tmp fix would be to edit get_revision:
if (quote) { string <- paste("\n\\begin{mdframed}\n", string, "\n\\end{mdframed}",collapse="") }

and add:
- \usepackage{mdframed}

to the reviewerComment addin

Damn, that's a curly one! Would be a good excuse to learn creating rmarkdown formats, but if it's a relatively minor edit we could always do a pull request for papaja.

tmp fix would be to edit get_revision:
if (quote) { string <- paste("\n\\begin{mdframed}\n", string, "\n\\end{mdframed}",collapse="") }

and add:
- \usepackage{mdframed}

to the reviewerComment addin

Not a bad option. I'll check out both. Thanks!

This hack fixes the problem by redefining in a {=tex} code chunck quote to mean mdframed:

\renewenvironment{quote}
  {% \begin{quote}
   \begin{mdframed}%
  }{% \end{quote}
   \end{mdframed}%
  }

@pdparker I have tried creating a new output format revise::letter, and added your previous fix to get_revision. Your code will be used when string lengths exceed 4800 characters (not sure if ever an advantage to using standard quote, if not we can just switch 100% to mdframed). This is now live in the latest version.

In my testing the issue is fixed, but let me know if you have any issues.
The required YAML setup is below:

---
title          : "Untitled"
authors        : "Author name on behalf of co-authors"
journal        : "your journal"
manuscript     : "MANUSCRIPT-ID"
handling_editor: ""

class             : "draft"

output            : revise::letter
---
\newcounter{C}

You no longer need a header-includes term.

Still getting errors for strings less that 4800. I think it might be worth just replacing framed with mdframed throughout.

@pdparker unfortunately I'm getting a weird issue with mdframed where references aren't getting converted correctly (they get left in their citekey form). Probably due to the csl I'm using if you are unaffected.

As a compromise I've lowered the threshold to 4500 and added an argument mdframed. If mdframed = TRUE it forces get_revision to use mdframed.

You'll just need to update your function at the top of the doc to:

get_revision <- function(id, ...) revise::get_revision(manuscript, id, ...)

in order to use

get_revision("myid", mdframed = TRUE)

I'll see if I can get mdframed to work correctly for me in which case I will replace throughout.

what happens if you add a =tex code chunk with:

\newenvironment{CSLReferences}% {\setlength{\parindent}{0pt}% \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces}%

it complained that CSLReferences was already defined. All good, I ended up using the code you posted above to redefine quote as mdframed.

\renewenvironment{quote}
  {% \begin{quote}
   \begin{mdframed}%
  }{% \end{quote}
   \end{mdframed}%
  }

I think not mdframed's fault, instead probably a quirk of pandoc. Now that it can be triggered with '>' everything is fine again. I have now replaced quote with mdframed by default.

This now opens up more styling options for quotes which we could consider (although the default behaviour is fine).

https://mirror.aarnet.edu.au/pub/CTAN/macros/latex/contrib/mdframed/mdframed.pdf