Closed jasonm closed 11 years ago
Looks like the spacing issue is not a pandoc issue, or even a LaTeX issue, but a PDF viewer issue:
http://tex.stackexchange.com/questions/62221/ensure-verbatim-code-block-is-copy-paste-able http://stackoverflow.com/questions/3527578/latex-listings-package-copy-pastable-listings
I haven't yet found a good solution.
As for the single quote issue, it seems that including the 'upquote' package in your template should fix that. (Though it may only work with standard verbatim environments, and not with our custom highlighted ones -- you should try it and let me know.)
I'm unsure about including it in the default template, because it's not a common package. But we could also just insert its code:
% code from upquote.sty
\newcommand\upquote@cmtt{cmtt}
\newcommand\upquote@OTone{OT1}
\ifx\encodingdefault\upquote@OTone
\ifx\ttdefault\upquote@cmtt\else\RequirePackage{textcomp}\fi
\else
\RequirePackage{textcomp}
\fi
% The \@noligs macro is called by \verb and \begin{verbatim} to turn the char-
% acters ` < > , ' - into active characters that merely print themselves rather
% than activating ligatures.
% This package merely adds code to \@noligs that changes the glyphs used for
% ` and '.
\begingroup
\catcode`'=\active
\catcode``=\active
\g@addto@macro\@noligs
{\let'\textquotesingle
\let`\textasciigrave
\ifx\encodingdefault\upquote@OTone
\ifx\ttdefault\upquote@cmtt
\def'{\char13 }%
\def`{\char18 }%
\fi\fi}
\endgroup
@jgm Thanks - adding the upquote package fixed the single quoting issue. The leading whitespace copy/paste seems to be much improved now too -- although that may be due to the TeXLive self update I had to run before installing the upquote package, not familiar enough to say.
I released a new version of highlighting-kate that uses \char18
and \char13
for the straight single quotes; this should fix the problem even without upquote.
Thanks, I'll give it a try.
A bit more info on the leading whitespace in PDF output: When I added upquote, I also switched to fontenc T1. I was running a BasicTeX installation which didn't have outline fonts for T1 fontenc, so this rendered bitmapped fonts which had copy/pasteable leading whitespace. I then installed the cm-super package to regain outline T1 font rendering, which then reverted back to lacking the copy/pasteable whitespace.
What version of pandoc are you using? 1.10.1 (the latest release) seems to have no problems with double quotes in code. If you disagree, please post markdown input I can use to reproduce the problem, together with the full command you used to generate the output.
+++ Asim Jalis [Mar 05 13 07:40 ]:
I have the same problem except with double-quotes. I want to use plain double-quotes in code. The solution above did not fix them. Any suggestions? Thanks!
— Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y6840FCeqSA4abC9vNnTqgsKfGhWimhddVugwWFu8a8t0Ct.gif]
References
The issue was caused by a template. When I got rid of the template the issue went away. So this is no longer an issue. Thanks! Also this is 1.10.1.
Hmm... using the upquote
package in my template didn't fix my quotes, nor did using highlighting-kate.
They are still curly.
Pandoc -v 1.11.1
Markdown example: http://pastebin.com/ztidR40Q
command: "pandoc book.md --data-dir=#{working} --template=pdf --variable monofont='Source Code Pro' --variable mainfont='Adelle Regular' --variable sansfont='Helvetica' --variable fontsize=12pt --latex-engine xelatex --chapters --highlight-style=tango --toc -o book.pdf"
I will say: removing the latex-engine specification fixes the issue, while at the same time breaks my custom fonts.
+++ Nathaniel Watts [Jun 25 13 18:28 ]:
Hmm... using the upquote package in my template didn't fix my quotes, nor did using highlighting-kate.
Why don't you reopen this issue. It seems that the fix works only for pdflatex, not xelatex.
I can't reopen unless I'm an admin --> created a new issue #889 (above)
Thanks for your help on this, @jgm! Pandoc is the jam!
Hi all,
I'm writing a technical book in Markdown, and distributing as (among other formats) PDF. I'm wondering if there's a way to improve the copy-paste-ability of the included code?
Code samples render beautifully in the PDF, but they lose their leading indentation when copy/pasted. Single quotes are also converted to smart quotes. I'm happy to split this into 2 issues if that's more appropriate.
Document generation:
Thank you for pandoc, and for any help on the issue.