我有一个将 Markdown 文件转换为 PDF 的项目,使用pandoc
LaTeX PDF 模板。
我在表格方面遇到了一个奇怪的问题。在极少数情况下(大约 200 份文档中只有 2 份),表格会插入到分页符后。我不确定这是否是分页符,因为我对 LaTeX 的使用经验很少,但看起来是这样的。
这是我正在转换的 Markdown 文件之一:
... More stuff above
Lorem
- Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
# LOREM IPSUM
## Lorem Ipsum is simply dummy
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting.
| Column 1 | Column 2 |
| ---------------------------------------------- | --------------------------------------------------------------------------- |
| Lorem Ipsum is simply dummy text | Lorem Ipsum |
| Lorem Ipsum is simply dummy text of the | Lorem Ipsum is simply dummy text of the printing and typesetting industry. |
## Lorem Ipsum is simply dummy text of the
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
... More stuff below
我的pandoc
命令是这样的(它用 Powershell 执行,这就是带有美元符号的变量的含义):
pandoc --metadata=title:"asasas" `
--resource-path="$markdownPath" `
--template="$pdfTemplatePath" `
--fail-if-warnings `
--variable numbersections="true" `
--variable mainfont="Arial" `
--variable sansfont="Helvetica" `
--variable monofont="Courier" `
--variable fontsize=12pt `
--variable version=2.0 `
--variable geometry="left=20mm, top=10mm, right=20mm, bottom=20mm" `
--variable toc-own-page="true" `
--toc `
--toc-depth=5 `
--lua-filter="version_table.lua" `
--variable titlepage="true" `
--variable logo="PDF/logo.eps" `
--columns=50 `
-f markdown-implicit_figures+escaped_line_breaks+raw_tex `
-t latex `
-s `
-o "$outputFileName" `
"$tempFileName"
我使用的 PDF 模板与pandoc-latex-模板,可能建在它上面。
当我运行pandoc
命令时,表的输出如下所示:
知道问题可能出在哪里吗?我应该尝试什么方法,能有所帮助吗?
这是上面截图中生成的 tex 文件的一部分
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames*,x11names*,table}{xcolor}
%
\documentclass[
12pt,
a4paper,
,tablecaptionabove
]{scrartcl}
\usepackage{lmodern}
\usepackage{setspace}
\setstretch{1.2}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage[utf8x]{inputenc}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
% \usepackage[utf8x]{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}
\setmainfont[]{Arial}
\setsansfont[]{Helvetica}
\setmonofont[]{Courier}
\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}
\definecolor{default-linkcolor}{HTML}{A50000}
\definecolor{default-filecolor}{HTML}{A50000}
\definecolor{default-citecolor}{HTML}{4077C0}
\definecolor{default-urlcolor}{HTML}{4077C0}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={asasas},
hidelinks,
breaklinks=true,
pdfcreator={LaTeX via pandoc with the Eisvogel template}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=2.5cm,includehead=true,includefoot=true,centering,left=20mm, top=10mm, right=20mm, bottom=20mm]{geometry}
\usepackage[export]{adjustbox}
\usepackage{graphicx}
\usepackage{longtable,booktabs}
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx,grffile}
\makeatletter
\def\ScaleWidthIfNeeded{%
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\def\ScaleHeightIfNeeded{%
\ifdim\Gin@nat@height>0.9\textheight
0.9\textheight
\else
\Gin@nat@width
\fi
}
\makeatother
\setkeys{Gin}{width=\ScaleWidthIfNeeded,height=\ScaleHeightIfNeeded,keepaspectratio}%
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
\usepackage{float}
\floatplacement{figure}{H}
\title{asasas}
\date{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,main=english]{babel}
\else
\usepackage{polyglossia}
\setmainlanguage[]{english}
\fi
\usepackage{pagecolor}
\usepackage{afterpage}
\usepackage{multicol}
\PassOptionsToPackage{hyphens}{url}
\usepackage{csquotes}
\definecolor{caption-color}{HTML}{777777}
\usepackage[font={stretch=1.2}, textfont={color=caption-color}, position=top, skip=4mm, labelfont=bf, singlelinecheck=false, justification=raggedright]{caption}
\setcapindent{0em}
\definecolor{blockquote-border}{RGB}{221,221,221}
\definecolor{blockquote-text}{RGB}{119,119,119}
\usepackage{mdframed}
\newmdenv[rightline=false,bottomline=false,topline=false,linewidth=3pt,linecolor=blockquote-border,skipabove=\parskip]{customblockquote}
\renewenvironment{quote}{\begin{customblockquote}\list{}{\rightmargin=0em\leftmargin=0em}%
\item\relax\color{blockquote-text}\ignorespaces}{\unskip\unskip\endlist\end{customblockquote}}
\definecolor{heading-color}{RGB}{40,40,40}
\addtokomafont{section}{\color{heading-color}}
\usepackage{titling}
\title{asasas}
\author{}
% tables
\definecolor{table-row-color}{HTML}{F5F5F5}
\definecolor{table-rule-color}{HTML}{999999}
\arrayrulecolor{table-rule-color} % color of \toprule, \midrule, \bottomrule
\setlength\heavyrulewidth{0.3ex} % thickness of \toprule, \bottomrule
\renewcommand{\arraystretch}{1.3} % spacing (padding)
\let\oldlongtable\longtable
\let\endoldlongtable\endlongtable
\renewenvironment{longtable}{
\rowcolors{3}{}{table-row-color!100} % row color
\oldlongtable} {
\endoldlongtable
\global\rownum=0\relax}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\usepackage{fancyhdr,lastpage}
\fancypagestyle{eisvogel-header-footer}{
\fancyhead{}
\fancyfoot{}
\lhead[]{asasas}
\chead[]{}
\rhead[asasas]{}
\lfoot{{Version: 2}{, effective date: 01-Sep-2020}}
\cfoot[]{}
\rfoot{{\thepage} of \pageref{LastPage}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\pagestyle{eisvogel-header-footer}
\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
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{colortbl}
\begin{document}
\arrayrulecolor{table-rule-color}
\restoregeometry
{
\setcounter{tocdepth}{5}
\tableofcontents
\newpage
}
\hypertarget{process-description}{%
\section{LOREM IPSUM}\label{process-description}}
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of
type and scrambled it to make a type specimen
book. It has survived not only five centuries, but
also the leap into electronic typesetting.
\hypertarget{objective-and-benefits}{%
\section{OBJECTIVE AND
BENEFITS}\label{objective-and-benefits}}
\hypertarget{objective}{%
\subsection{Objective}\label{objective}}
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the
industry's standard
\hypertarget{benefits}{%
\subsection{Benefits}\label{benefits}}
\begin{itemize}
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry.
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry.
\end{itemize}
\hypertarget{definition}{%
\section{DEFINITION}\label{definition}}
Lorem Ipsum
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry.
\end{itemize}
Lorem Ipsum
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the
1500s, when an unknown printer took
\end{itemize}
Lorem Ipsum
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the
industry's standard dummy
\end{itemize}
Lorem Ipsum
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text
\end{itemize}
Lorem
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum is
\end{itemize}
Lorem
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum is
\end{itemize}
\hypertarget{roles-responsibilities}{%
\section{LOREM IPSUM}\label{roles-responsibilities}}
Lorem
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since
the 1500s Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since
the 1500s.
\end{itemize}
Lorem
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lore
\end{itemize}
Lorem
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry.
\end{itemize}
Lorem
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since
the 1500s.
\end{itemize}
Lorem
\begin{itemize}
\tightlist
\item
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been
the industry's standard dummy text ever since
the 1500s.
\end{itemize}
\hypertarget{lorem-ipsum}{%
\section{LOREM IPSUM}\label{lorem-ipsum}}
\hypertarget{lorem-ipsum-is-simply-dummy}{%
\subsection{Lorem Ipsum is simply
dummy}\label{lorem-ipsum-is-simply-dummy}}
Lorem Ipsum is simply dummy text of the printing
and typesetting industry. Lorem Ipsum has been the
industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of
type and scrambled it to make a type specimen
book. It has survived not only five centuries, but
also the leap into electronic typesetting.
\begin{longtable}[]{@{}ll@{}}
\toprule
\begin{minipage}[b]{0.36\columnwidth}\raggedright
Column 1\strut
\end{minipage} &
\begin{minipage}[b]{0.58\columnwidth}\raggedright
Column 2\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.36\columnwidth}\raggedright
Lorem Ipsum is simply dummy text\strut
\end{minipage} &
\begin{minipage}[t]{0.58\columnwidth}\raggedright
Lorem Ipsum\strut
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.36\columnwidth}\raggedright
Lorem Ipsum is simply dummy text of the\strut
\end{minipage} &
\begin{minipage}[t]{0.58\columnwidth}\raggedright
Lorem Ipsum is simply dummy text of the printing
and typesetting industry.\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}
\end{document}