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

Horizontal rule in latex output no longer works with recent texlive #5801

Closed
marek-step opened this issue Oct 7, 2019 · 23 comments
Closed

Comments

@marek-step
Copy link

marek-step commented Oct 7, 2019

Is there a change with horizontal lines? After Homebrew update my markdown file is not compiling with pandoc anymore. I have this error now related to horizontal lines:

`
Error producing PDF.
! Missing number, treated as zero.

\protect
l.153 ...nter}\rule{0.5\linewidth}{\linethickness}

make: *** [typeset] Error 43
`

And I am wondering, whether pandoc is not replacing these lines with the definition of \HRline defined in the template.

What I did so far to resolve this issue: I changed all horizontal lines in file.md
3 Hyphens 3 Underscores 3 Asterix
to:
\HRule
Surrounded by empty lines. And the definition of it in the Headers of my template.tex to:
\newcommand{\HRule}{\begin{center}\rule{0.5\linewidth}{0.2mm}\end{center}}

Working now!

My Platform: Mac Mojave,
Homebrew 2.1.12
Homebrew/homebrew-core (git revision 5b995; last commit 2019-10-05)
Homebrew/homebrew-cask (git revision a8417a; last commit 2019-10-05)
pandoc 2.7.3
Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.8.1
Default user data directory: /Users/mstep/.local/share/pandoc or /Users/mstep/.pandoc

@alerque
Copy link
Contributor

alerque commented Oct 7, 2019

Given that the LaTeX code you are generating is exactly what pandoc is generating, I'm not sure what could be going on here:

$ pandoc -t latex <<< "***"
\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}

Have you customized your template or included something else that would have messed with the LaTeX definition for \rule perhaps?

@marek-step
Copy link
Author

Thank you alerque for this speedy reply. Unfortunately I can't tell, whether it's the update of pandoc (with homebrew) or the update of my LaTeX, which broke things; I made both updates one after the other. After these updates, I got error messages, from pandoc and pdflatex in my vim saying:

LaTeX Warning: Command \InputIfFileExists has changed. 27 Check if current package is valid.

So I suppose there is something wrong with my texlive install. I will dig into it, or wait for the next update of texlive.

Thank you for the pandoc -t latex <<< "***" command! Did not know that! Really impressing!

Thx again

@alerque
Copy link
Contributor

alerque commented Oct 7, 2019

Have you tried boiling this down to a minimum example? Get out of your problem document, leave that folder, go work in a blank space from scratch and try something simple like

$ pandoc -o hr.pdf <<< "***"

Does hr.pdf get built with a horizontal line? If not is the error the same or different? If so, start a test file and start adding features of your failing document until it fails (or start stripping things from your failing one until it works).

@marek-step
Copy link
Author

marek-step commented Oct 7, 2019

Wow! Did not know this command either! Here the result of it:

pandoc -o hr.pdf <<< "***"
Error producing PDF.
! Missing number, treated as zero.
<to be read again>
\protect
l.51 ...enter}\rule{0.5\linewidth}{\linethickness}

No PDF is produced ...
Which line 51 is meant? Thx again!

@alerque
Copy link
Contributor

alerque commented Oct 7, 2019

LaTeX error messages tend to be a bit cryptic, but I'm guessing that's going to be line 51 of the standalone TeX file created by Pandoc as an intermediary to generating the PDF. Speaking of which if you can post the output of that I'll check to see if it's different than mine:

$ pandoc -s -o test.tex <<< "***"

Attach that file here or post it to a pastbin of some kind. If you happen to have Netcat installed you cat try this:

$ pandoc -s -t latex <<< "***" | nc termbin.com 9999

That will post the generated LaTeX directly and give you a URL back you can copy here.

(Note the <<< syntax is just bash syntactical sugar for echo "***" | pandoc ..., it just feeds a string into STDIN, nothing too magic.)

@marek-step
Copy link
Author

I am learning a lot with this thread! I am very grateful for your input ... I just installed netcat and the resulting URL is:

https://termbin.com/0g5r
The output of the TeX-File seams to work:

% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
  hidelinks,
  pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering

\date{}

\begin{document}

\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}

\end{document}

Best greetings from Munich - Everybody is digesting the bear from Oktoberfest, except me!

@alerque
Copy link
Contributor

alerque commented Oct 7, 2019

I just compared your dump with mine and they are bit for bit identical. This suggests that it was something that got buggered up in your LaTeX installation rather than with Pandoc.

I'm curious if you can run xelatex text.tex on that standalone tex file created above. Does that give you any flack? Any more useful error output?

@marek-step
Copy link
Author

I am always compiling with pdflatex. The test with xelatex and pdflatex are spitting out an empty pdf
The errors are similar (I include a hyperref warning):

Package hyperref Warning: Rerun to get /PageLabels entry.

! Missing number, treated as zero.
<to be read again>
                   \protect
l.51 ...enter}\rule{0.5\linewidth}{\linethickness}
                                                  \end{center}
?
! Illegal unit of measure (pt inserted).
<to be read again>
                   \protect
l.51 ...enter}\rule{0.5\linewidth}{\linethickness}
                                                  \end{center}

With pdflatex I get:

! Missing number, treated as zero.
<to be read again>
                   \protect
l.51 ...enter}\rule{0.5\linewidth}{\linethickness}
                                                  \end{center}
?
! Illegal unit of measure (pt inserted).
<to be read again>
                   \protect
l.51 ...enter}\rule{0.5\linewidth}{\linethickness}
                                                  \end{center}
?

You are certainly right. There is something wrong after the last update of texlive ...

marek

@alerque
Copy link
Contributor

alerque commented Oct 8, 2019

The problem is unlikely to be something in texlive itself, I'm guessing something is borked about the Homebrew packaging or, even more likely, your specific system. I would try a force re-install or uninstall/install of the entire texlive ball of wax — whatever it gives you the option for. I'm sorry it's been a while since I was hands on with brew so I can't remember exactly what you're options are, but support channels or filing an issue with Homebrew is probably your next recourse. Given the evidence so far I'm pretty confident there is not an issue with Pandoc to be resolved here.

@marek-step
Copy link
Author

Thx again alerque

I can live with horizontal lines \HRule and definition of it in the tex.template headers: \newcommand{\HRule}{\begin{center}\rule{0.5\linewidth}{0.2mm}\end{center}}

pandoc is incredibly smart and I am big fan of my combo: markdown -> Makefile (JSON) -> LaTeX -> PDF

I am writing Books with it, many many pages ...

Best greetings

marek

@jgm jgm closed this as completed Oct 11, 2019
@bogdanni
Copy link

This issue occurs with the current up-to-date version of TexLive.

@marek-step
Copy link
Author

Thx bogdanni
So we have to be patient and wait some updates of texlive ...

Best greetings

@alerque
Copy link
Contributor

alerque commented Oct 12, 2019

@jgm We should probably re-open this and look into what's coming down the pike from LaTeX.

@wilx
Copy link
Contributor

wilx commented Oct 12, 2019

I have hit this too just today but I did not realize it was Pandoc's fault. See TeX, LaTeX and Friends | chat.stackexchange.com chat transcript. It previously only worked accidentally. The solution is to use \@wholewidth as the 2nd argument of the \rule.

@jgm jgm reopened this Oct 13, 2019
@jgm
Copy link
Owner

jgm commented Oct 13, 2019

I guess I didn't understand the issue (maybe I still don't). What has changed, exactly, in recent LaTeX? What should be changed in pandoc?

@jgm jgm changed the title Horizontal-Line Horizontal rule in latex output no longer works with recent texlive Oct 13, 2019
@jgm
Copy link
Owner

jgm commented Oct 13, 2019

I can reproduce the problem now, having updated texlive.

@jgm jgm added this to the 2.8 milestone Oct 13, 2019
@jgm jgm closed this as completed in d9db76d Oct 13, 2019
@cbrnr
Copy link

cbrnr commented Oct 14, 2019

Thanks @jgm for fixing this. I'm using horizontal rules in many RMarkdown and Jupyter notebooks, which at the moment can't be converted to PDF. Is the 2.8 release planned to be released anytime soon?

@jgm
Copy link
Owner

jgm commented Oct 14, 2019

There are still some features we're waiting on for a 2.8 release. I'd say within a month.
In the mean time you can use a nightly if you need to, or refrain from updating texlive.

I'd be curious to get feedback on this question from everyone: would it be better to define \HRule in the default template and use it, rather than hard-coding? Advantages: customization, easier to read. Disadvantage: the LaTeX won't work without the macro defined in the template, so it's not as good for fragments.

@cbrnr
Copy link

cbrnr commented Oct 14, 2019

Thanks, this sounds good. I'm definitely +1 to keep it hard-coded because I prefer if things just work. Unless you can define a default value, but I guess that's not possible.

@aourednik
Copy link

aourednik commented Oct 28, 2019

I can reproduce the bug with pandoc 2.7.3 In my case the engine is LuaLatex 1.10.0, TeXLive 2019. My template file is the one provided by the rmarkdown package of RStudio.

pandoc -o my.pdf --pdf-engine=lualatex --template=latextemplate05.tex temp.html

yields

Error producing PDF.
! Missing number, treated as zero...

Having a look at the intermediary tex file:

pandoc -o my.tex --pdf-engine=lualatex --template=latextemplate05.tex temp.html

I can find this faulty line in my.tex

\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}

@marek-step 's workaround put me on the right track, though I could not apply it as such to my case (I am not converting md -> tex -> pdf but html -> tex -> pdf, thus inserting \HRule in the md file was not an option)

Anyway, this is announced to be fixed in pandoc 2.8. For the time being, I've got an easier workaround. Add this line to the latextemplate.tex file:

\renewcommand{\linethickness}{0.05em}

Set the linethicknness to whatever you want. Works for me (can others confirm?).

lcreteig added a commit to lcreteig/amsterdown that referenced this issue Oct 30, 2019
@vladimiroff
Copy link

@jgm have you considered backporting this fix to a 2.7.x release?

@mb21
Copy link
Collaborator

mb21 commented Nov 7, 2019

We generally don't do that. However, you can use the nightly builds...

@jgm
Copy link
Owner

jgm commented Nov 7, 2019

I hope to have 2.8 out in the next couple weeks

clrpackages pushed a commit to clearlinux-pkgs/R-rmarkdown that referenced this issue Jan 22, 2020
… 2.1

Andrew Dunning (1):
      Provide @adunning's ORCID ID (#1736)

Barret Schloerke (1):
      Return output from shiny::runApp() within rmarkdown::run() (#1760)

Christophe Dervieux (1):
      fix #1747: correctly parse yaml front matter in html_notebook's intermediate knit files (#1758)

Lanfeng Pan (1):
      Add the missing slash in the html <meta> tag (#1737)

Yihui Xie (14):
      start the next version
      missing ) from #1736
      make sure HTML dependencies can be written out even if the tempdir() has been wiped out, e.g.
      use a more general fix to the previous issue: change the default of tempfile(tmpdir = ) to tempdir(TRUE)
      make sure the first argument of tempfile() is `pattern`
      fix #1742: since html_vignette() uses doesn't use themes, there won't be a #header element in the output, so it doesn't make sense to center it here
      fix #1743: use dir.create() to create the tempdir explicitly, instead of calling tempdir(TRUE), because the latter requires R >= 3.5.0
      support slide_level in slidy_presentation(): https://stackoverflow.com/q/59157211/559676
      remove the hard dependency on jQuery: rstudio/rmarkdown#1732 (comment)
      we don't generate <section> in html_document() (because we only support html4 in R Markdown)
      roxygenize
      delete two unused functions (copied from knitr)
      fix horizontal rules for .tex output generated by Pandoc < 2.8 (jgm/pandoc#5801)
      CRAN release v2.1

atusy (1):
      update documentation of df_print (#1749)

jooyoungseo (1):
      Fixed #1663: empty h2 tag for empty subtitle in ioslides_presentation (#1735)

* Added a new (experimental) output format `powerpoint_presentation`. If you want to test it, you will need Pandoc >= 2.1 (#1231).

## MAJOR CHANGES

* If the **tinytex** package is installed, PDF output is built through `tinytex::latexmk()`, otherwise it is generated by `rmarkdown:::latexmk()`, which has been factored out and improved in the **tinytex** package, so it is recommended that you install the **tinytex** package (#1222).

## BUG FIXES

* Temporary files created in `render()` may be cleaned up prematurely, which can cause problems with Shiny R Markdown documents (#1184).
glimmerphoenix added a commit to glimmerphoenix/cursoLatex that referenced this issue Feb 23, 2021
Más info: jgm/pandoc#5801.
Propongo la solución aparentemente más sencilla.
Funciona con pdflatex y xelatex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants