eddelbuettel / pinp

Pinp Is Not PNAS -- Two-Column PDF Template
147 stars 25 forks source link

Preserve non-fancy quotes in code chunks #75

Closed riccardoporreca closed 5 years ago

riccardoporreca commented 5 years ago

Using output: pinp::pinp, the quotes in the code chunks are converted to fancy quotes.

I quickly constructed a minimal example as follows

---
title: "Test pinp quotes"
output: pinp::pinp
---

Pinp's quotes in regular text: "dquoted", 'squoted', \`bquoted\`.

Pinp's quotes in inline verbatim text: `"dquoted"`, `'squoted'`.

```r
"dquoted"
'squoted'
`bquoted`
#' Xyz's "dquoted" 'squoted' `bquoted`

(I did not find a nice way to render the closing ``` of the code chunk)

This results in image

Not sure if this is a desired behavior (I noticed it for the Rcpp vignettes), but in case I tried a quick fix by using LaTeX package upquote. In particular, adding

\RequirePackage{upquote} % For keeping actual quotes in verbatim

to the class definition pinp.cls seemed to indeed help: image

My LaTeX skills are a bit rusty, so maybe there are more convenient / appropriate ways to achieve the same.

eddelbuettel commented 5 years ago

Nice catch. I may be a little dense but the desired effect is just for the verbatim chunk, correct? Inline does not seem to change. Or am I missing something?

riccardoporreca commented 5 years ago

the desired effect is just for the verbatim chunk, correct? Inline does not seem to change. Or am I missing something?

From what I see it doesn't seem to affect anything inline (even verbatim inline which was already OK), since inline stuff do not use any of the verbatim-related LaTeX affected by upquote, see the generated LaTeX code:

Pinp's quotes in regular text: ``dquoted'', `squoted', `bquoted`.

Pinp's quotes in inline verbatim text: \texttt{"dquoted"},
\texttt{\textquotesingle{}squoted\textquotesingle{}}.

\begin{Shaded}
\begin{Highlighting}[]
\StringTok{"dquoted"}
\StringTok{'squoted'}
\StringTok{`}\DataTypeTok{bquoted}\StringTok{`}
\CommentTok{#' Xyz's "dquoted" 'squoted' `bquoted`}
\end{Highlighting}
\end{Shaded}

(I have updated the example with something a little more accurate / sensible)

eddelbuettel commented 5 years ago

Ok, I just tossed that in with a simple commit. Thanks again for the suggestion!

riccardoporreca commented 5 years ago

Cool, I will be trying it out very soon while drafting a review of the Rcpp-modules vignette as discussed in https://github.com/RcppCore/Rcpp/issues/976#issuecomment-512543279.