使用 rmarkdown/pandoc 时出错

使用 rmarkdown/pandoc 时出错

我正在使用 Rmarkdown(以及 Pandoc)在 Ubuntu 18.04 上创建 PDF。但是,我收到以下错误

LaTeX Font Info:    Try loading font information for T1+lmtt on input line 139.

    (/home/user/texmf/tex/latex/lm/t1lmtt.fd
File: t1lmtt.fd 2009/10/30 v1.6 Font defs for Latin Modern
)
LaTeX Font Info:    Font shape `T1/lmtt/bx/n' in size <10> not available
(Font)              Font shape `T1/lmtt/b/n' tried instead on input line 173.
 [1

{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}
! pdfTeX error (font expansion): auto expansion is only possible with scalable 
fonts.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox 
                                                  \fi \fi 
l.213 \begin{Shaded}

我在 Google 上搜索,发现各种页面都表明各种免费软件包存在延迟问题。安装它们似乎没有帮助。以下是我目前拥有的列表apt list --installed | grep '^tex\|^cm'

cm-super/bionic,bionic,now 0.3.4-11 all [installed]
cm-super-minimal/bionic,bionic,now 0.3.4-11 all [installed,automatic]
tex-common/bionic,bionic,now 6.09 all [installed,automatic]
tex-gyre/bionic,bionic,now 20160520-1 all [installed]
texinfo/bionic,now 6.5.0.dfsg.1-2 amd64 [installed]
texlive/bionic,bionic,now 2017.20180305-1 all [installed]
texlive-base/bionic,bionic,now 2017.20180305-1 all [installed]
texlive-binaries/bionic-updates,bionic-security,now 2017.20170613.44572-8ubuntu0.1 amd64 [installed]
texlive-extra-utils/bionic,bionic,now 2017.20180305-2 all [installed]
texlive-font-utils/bionic,bionic,now 2017.20180305-2 all [installed,automatic]
texlive-fonts-extra/bionic,bionic,now 2017.20180305-2 all [installed]
texlive-fonts-recommended/bionic,bionic,now 2017.20180305-1 all [installed]
texlive-generic-recommended/bionic,bionic,now 2017.20180305-1 all [installed]
texlive-humanities/bionic,bionic,now 2017.20180305-2 all [installed]
texlive-lang-english/bionic,bionic,now 2017.20180305-1 all [installed,automatic]
texlive-lang-greek/bionic,bionic,now 2017.20180305-1 all [installed,automatic]
texlive-latex-base/bionic,bionic,now 2017.20180305-1 all [installed]
texlive-latex-extra/bionic,bionic,now 2017.20180305-2 all [installed]
texlive-latex-recommended/bionic,bionic,now 2017.20180305-1 all [installed]
texlive-pictures/bionic,bionic,now 2017.20180305-1 all [installed]
texlive-plain-generic/bionic,bionic,now 2017.20180305-2 all [installed,automatic]
texlive-pstricks/bionic,bionic,now 2017.20180305-2 all [installed,automatic]
texlive-publishers/bionic,bionic,now 2017.20180305-2 all [installed]
texlive-science/bionic,bionic,now 2017.20180305-2 all [installed]
texmaker/bionic,now 5.0.2-1build2 amd64 [installed]
texmaker-data/bionic,bionic,now 5.0.2-1build2 all [installed,automatic]

Pandoc 创建的序言包含以下内容

\documentclass[]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
            pdftitle={Comparing methods for time varying logistic models},
            pdfauthor={Benjamin Christoffersen},
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{248,248,248}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}}
\newcommand{\ImportTok}[1]{#1}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}}
\newcommand{\BuiltInTok}[1]{#1}
\newcommand{\ExtensionTok}[1]{#1}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{#1}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{#1}
\usepackage{longtable,booktabs}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}

%%% Change title format to be more compact
\usepackage{titling}

\usepackage{bm}
\begin{document}
%...
\texttt{dynamichazard} with others methods within the package and % <-- line 139
%...
\begin{Shaded}
\begin{Highlighting}[] % <-- line 172
\NormalTok{devtools}\OperatorTok{::}\KeywordTok{install_github}\NormalTok{(current_version)}
\end{Highlighting}
\end{Shaded}
%...
\begin{Shaded} % <-- line 213
\begin{Highlighting}[]
\KeywordTok{head}\NormalTok{(pbc2)}
\end{Highlighting}
\end{Shaded}

答案1

我不知道我做错了什么。我最终使用这个答案,并删除以下目录和texmaker

sudo rm -rf /usr/share/texmf/
rm -rf ~/texmf/
sudo apt-get remove texmaker
sudo apt autoremove 

然后我重新安装了大部分软件包,如下所示

sudo apt-get install texlive-fonts-recommended
sudo apt-get install texlive-fonts-extra
sudo apt-get install texlive-latex-extra
sudo apt-get install texmaker

然后一切就正常了。

相关内容