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

markdown -> pdf: error; math in \href description fails, latex writer bug? #583

Closed
ViktorQvarfordt opened this issue Aug 13, 2012 · 7 comments

Comments

@ViktorQvarfordt
Copy link

Reproducing:

me@host:~$ echo '..text.. [$\LaTeX$](http://example.org) ..text..' | pandoc -f markdown -o test.pdf
pandoc: Error producing PDF from TeX source.
! You can't use `\spacefactor' in math mode.
\@->\spacefactor 
                 \@m 
l.35 ..text.. \href{http://example.org}{$\LaTeX$}

This does with html writer, so I assume this is a bug in the LaTeX writer.

@jgm
Copy link
Owner

jgm commented Aug 13, 2012

+++ Viktor Qvarfordt [Aug 13 12 00:10 ]:

Reproducing:
me@host:~$ echo '..text.. $\LaTeX$ ..text..' | pandoc -f m
arkdown -o test.pdf
pandoc: Error producing PDF from TeX source.
! You can't use `\spacefactor' in math mode.
@->\spacefactor
@m
l.35 ..text.. \href{http://example.org}{$\LaTeX$}

This does with html writer, so I assume this is a bug in the LaTeX
writer.

No, it's not a bug in pandoc. In LaTeX, the macro
\LaTeX cannot be used in math mode. You can verify this
by trying a simple latex document that contains just

$\LaTeX$

in the body. It will crash just as above. With

\LaTeX

it works fine. So, you can change your source to

[\LaTeX](http://example.org)

Note, however, that this won't work in HTML, since you're using
raw LaTeX outside math mode.

@ViktorQvarfordt
Copy link
Author

Hmm I see. Can this not be solved in some nice way? Pandoc is really great for writing documents in a syntax that is nice looking and manageable, like markdown, and still being able to output to a nice looking and powerful format, like html and latex.

But in this case I need to modify the source each time I want another output format. Can I not get around this?

@jgm
Copy link
Owner

jgm commented Aug 13, 2012

If you are just targetting HTML and PDF, you can do the following.
Create an image with the LaTEX symbol, then do the following:

[\LaTeX <img src="latex.png" />](/url)

The raw LaTeX will only appear in latex/PDF. The raw HTML will only appear
in HTML. Either way you'll get your symbol.

+++ Viktor Qvarfordt [Aug 13 12 12:26 ]:

Hmm I see. Can this not be solved in some nice way? Pandoc is really
great for writing documents in a syntax that is nice looking and
manageable, like markdown, and still being able to output to a nice
looking and powerful format, like html and latex.

But in this case I need to modify the source each time I want another
output format. Can I not get around this?


Reply to this email directly or [1]view it on GitHub.
[xJAuenYDiIoVt3LF3y6848DAslDCyjnQ6q-QyN4VMN89YF7234dexszSvB9csk3I.gif]

References

  1. markdown -> pdf: error; math in \href description fails, latex writer bug? #583 (comment)

@jgm jgm closed this as completed Aug 24, 2012
@v1kn
Copy link

v1kn commented Jan 5, 2017

@jgm
I frequently convert my md notes into both html and pdf files, the comment You made directly above really suits my usecase (I'd like to be able to use \LaTeX in both formats.

However, I don't know how I should do it, the link in Your comment seems broken. Could You please repeat the correct way of configuring pandoc to display the latex command in both html and pdf at the same time?

Furthermore, below command that has \LaTeX in test.md works.

pandoc -f markdown test.md -o test.pdf

However, if I change markdown to markdown_github, the command stops working. Unfortunately I always use the github variant when writing my md files.

I used this section on markdown variants from pandoc documentation, and I subtracted all the extensions from the variant, like so:

pandoc -f markdown_github-pipe_tables-raw_html-etc

But, even when I substract all the extensions from markdown_github, the command still does not work, treating \LaTeX verbatim. Thus, I don't know which part of markdown_github prevents \LaTeX from being properly displayed.

So, in summary, I'd like to ask whether there is a way for me, to be able to use \LaTeX in my md files, that will be properly converted into both html and pdf, and while using markdown_github as an input format.

@suknat
Copy link

suknat commented Jan 17, 2017

@jgm There does seem to be a problem with your post of Aug 13 2012. Any chance you could repost this?

I tried using pandoc-tex2svg to solve this but that simply produced a PDF with no math! Oddly (or perhaps not so oddly to those who understand these things better) no error message was produced.

@jgm
Copy link
Owner

jgm commented Jan 17, 2017

I updated the comment.

@suknat
Copy link

suknat commented Jan 17, 2017

Thanks @jgm that works, in principle. In practice, the image now has to be scaled to some target size so it can appear inline. Can't do html width/height adjustment as those cannot be made relative to the size of the text AFAIK. My output formats are PDF or epub, hence the need to worry about multiple font sizes.

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

4 participants