“产生错误的PDF";当降价包含水平规则时:---或*** [英] "Error Producing PDF" when markdown contains a horizontal rule: --- or ***

查看:122
本文介绍了“产生错误的PDF";当降价包含水平规则时:---或***的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的Markdown文件包含水平线时---或***我收到关于\ Linethickness-> \ Protect

When my Markdown file contains a horizontal rule --- or *** I receive an error regarding \Linethickness -> \Protect

我了解到最近MiKTeX出现了问题,但是我不确定它们是否适用于此.

I understand there have been issues with MiKTeX recently, however I am unsure whether they apply here.

自昨天早上以来,我一直在遇到这个问题,当时我正在尝试让Lato字体包与一组Markdown文件一起使用,我需要将这些文件转换为PDF.一切正常(字体问题方面也是如此).

I have been experiencing this issue since yesterday morning, when I was playing around trying to get the Lato font package to work with a set of Markdown files I need to convert to PDF. It had been working fine (asides from the font issue).

这可能是我更新MiKTeX时发生的,尽管当时我还没有意识到可能是这样,因为我还在玩模板,YAML,PS Script等.

This could have happened when I updated MiKTeX, although at the time I hadn't realised that could be the case, as I was also playing with the templates, YAML, PS Script etc.

从那时起,我一直在阅读有关MiKTeX的问题,并尝试了进一步的更新,更新程序包数据库,构建格式,刷新文件名数据库以及卸载和重新安装.我已经阅读了 GitHub 上的注释部分的背景,但是那里的建议确实可以似乎没有为我解决它,而为其他人解决了.

Since then I've been reading about the MiKTeX issue and I've tried further updates, updating package database, building formats, refreshing file name database and uninstalling and reinstalling. I have read the background in the comments section on GitHub but the suggestions there do not seem to have solved it for me, whereas they have for others.

这使我怀疑这是否相关,但是对于Tex,Markdown等我还是比较陌生.

This makes me question whether this is related, but I am relatively new to Tex, Markdown etc.

原始文件更长,更复杂,但是这次降价

The original file was longer and more complex, but this Markdown

# Sample File
Test Test Test

---

产生相同的错误

Error producing PDF.
! Missing number, treated as zero.
<to be read again>
                   \protect
\linethickness ->\protect
                          \linethickness
\setlength #1#2->#1 #2
                      \relax
\@rule ...@tempdimb {#2}\setlength \@tempdimc {#3}
                                                  \advance \@tempdimc \@temp...
l.362 ...nter}\rule{0.5\linewidth}{\linethickness}

删除---允许pdf在上述示例和我更复杂的markdown文件中生成,即使使用模板也是如此.

Removing the --- allows the pdf to generate in both the above example and my more complex markdown file, even with templates.

我不确定线厚是否在图形软件包中,当我查看软件包信息时,我看不到任何明显的迹象.

I am unsure if linethickness is within the graphics package, when I look at package information I can't see anything that obviously indicates it is.

我只删除有问题的行,但是在降价文件的其余部分中会使用它们,如果可能的话,我希望在您的帮助下找到一个解决方法! 请让我知道我是否因最近的MiKTeX问题在错误的树上吠叫,如果不​​是,则可能是我出了问题. 非常感谢.

I would simply remove the offending lines but they are used throughout the remainder of the markdown files and I would prefer to find a fix, with your help, if possible! Please could you let me know if I'm barking up the wrong tree with this recent MiKTeX issue or not, and if not, where I might be going wrong. Many Thanks in advance.

更新: 我执行了这个命令

Update: I ran this command

pandoc -s sample.md -o sample.tex

产生这个tex:

% 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
\usepackage[margin=1cm]{geometry}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering

\date{}

\begin{document}

\setcounter{errorcontextlines}{40}

\hypertarget{sample-file}{%
\section{Sample File}\label{sample-file}}

Test Test Test

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

\end{document}

推荐答案

同时,我尝试了此操作(作为RStudio Debian最新安装的根目录):

meanwhile, I tried this (as root in a latest RStudio Debian install):

~# sed 's,\\linethickness,0.5000000000pt,g' < pandoc/pandoc > /usr/lib/rstudio-server/bin/pandoc/pandoc

其中第一个pandoc/pandoc是软件包中原始文档的副本.这样可以保持相同的字符串长度和有效数字,以使二进制文件不会中断.那写成这样的小题为:

where the 1st pandoc/pandoc is a copy of the original from package. That keeps the same string length and valid number so that the binary won't break. That writes the hrule as:

\begin{center}\rule{0.5\linewidth}{0.5000000000pt}\end{center}

MiKTeX看起来不错(至少TeXworks可以编译pdf).

and MiKTeX seems fine with it (at least TeXworks compiles the pdf).

HTH 再见

这篇关于“产生错误的PDF";当降价包含水平规则时:---或***的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆