Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug report about # in \passthrough #4922

Closed
bubifengyun opened this issue Sep 21, 2018 · 6 comments
Closed

bug report about # in \passthrough #4922

bubifengyun opened this issue Sep 21, 2018 · 6 comments

Comments

@bubifengyun
Copy link

pandoc version

pandoc 2.3
Compiled with pandoc-types 1.17.5.1, texmath 0.11.1, skylighting 0.7.2

little example

input

# file: input.tex
# skip some code
\passthrough{\lstinline!#!} and \lstinline!#! are not the same.

exact command

xetex input.tex

output

_ _20180921094156

I hope it is # and # are not the same, but it shows ## and # are not the same.

solution

how to disable passthrough, I find that it cannot work in mathescape mode #4716

It does not work as expected. It leads to many bugs, Just like IE in windows.

@jgm
Copy link
Owner

jgm commented Sep 21, 2018

I don't understand this bug report. Since this is a bug tracker for pandoc, not xetex, please give the exact pandoc command you are using, together with the full input and the actual and expected output.

@bubifengyun
Copy link
Author

Thank you. it is not pandoc's bug. Sorry for that.

@bubifengyun
Copy link
Author

Thank you, I find that it is CTexBook 's bug.

CTeX-org/ctex-kit#378
I had read the lastest listings.pdf. Hope well.
https://www.ctan.org/tex-archive/macros/latex/contrib/listings

@TravisCardwell
Copy link

TravisCardwell commented Jul 16, 2019

This issue is closed, but I have spent some time on it after running into it myself and figure that it is worth adding a comment to save time of any others who run into the issue.

The \passthrough command, defined in default.latex, does not work well with XeTeX, xeCJK, and listings. Pandoc writes LaTeX source \passthrough{\lstinline!CONTENT!}, and any hash character (#) in the content is doubled (##) in the output PDF file.

LaTeX package cprotect defines a macro \cprotect that allows verbatim arguments to be passed to macros. Hash characters are no longer doubled when LaTeX code like the above is rewritten as \cprotect\passthrough{\lstinline!CONTENT!}, so one can work around the issue by instructing Pandoc to write LaTeX, translating the LaTeX, and then building the PDF from the translated LaTeX using XeTeX.

Minimal Pandoc demo

# Demo

* <https://ja.wikipedia.org/wiki/Pandoc>
* [`https://ja.wikipedia.org/wiki/Pandoc#カスタムフォーマット`](https://ja.wikipedia.org/wiki/Pandoc#%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88)

To build:

$ pandoc --pdf-engine xelatex --listings \
  -V "CJKmainfont=fonts-japanese-mincho.ttf" \
  --output demo.pdf demo.md

Motivation:

CJK characters in URLs are escaped, which often results in very long URLs. The goal of the second URL above is to include a readable URL on a printed page with a valid/escaped hyperlink for digital viewers. The link text is readable both in that it is not escaped as well as in that it fits on the page. The link text is verbatim so that it matches the style of non-CJK URLs like the first URL above.

Minimal LaTeX demo

The issue is due to the definition and usage of \passthrough, so here is a minimal demo created by minimizing Pandoc's LaTeX output:

\documentclass[10pt,a4paper,oneside]{report}

\usepackage{xeCJK}
\setCJKmainfont{IPAPMincho}
\setCJKsansfont{IPAPGothic}
\setCJKmonofont{IPAGothic}

\usepackage{listings}
\newcommand{\passthrough}[1]{#1}

\begin{document}

\lstinline!#!

\passthrough{\lstinline!#!}

\passthrough{\lstinline!http://www.example.com/index.html#anchor!}

\end{document}

To build:

$ xelatex demo.tex

Note:

Pandoc supports setting CJKmainfont but not CJKsansfont or CJKmonofont. When writing to PDF, the resulting warnings are not shown. In production, I use a custom template that hard-codes the fonts. This LaTeX demo sets the fonts as well, as the warnings are unrelated to this issue.

@bubifengyun
Copy link
Author

thank you very much, let me take a try

@bubifengyun
Copy link
Author

Thank you very much. Now it works well without setting anything. Maybe some software had overcome this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants