我目前正在使用我制作的模板生成具有可变内容的 PDF。数据从数据库中提取并用于创建报告。这一直很有效,直到最近我需要更改布局。
在一系列传统的描述环境中,我设置了一个包含特定分数的项目。例如\item[1/2]。此后,小节* 将作为标题,后面跟着一段简单的文字。
当数据库没有文本可插入 subsubsection* 主体时,就会出现问题。我收到众所周知的“可能缺少 \item”错误。
有没有办法解决?
*编辑:以下是功能代码。哈哈,我猜 \noindent 是标题仍设置为侧标签时的残留代码(说实话,我也不确定这是否重要)。
我需要一个标记,即使没有文本可放入特定列表环境的主体中,它也能打印标题和分数。
非常欢迎对全新解决方案的建议..不希望 LaTeX 一直处于等待发生错误的状态。
\documentclass[11pt, a4paper]{article}
% DOCUMENT LAYOUT
\usepackage{geometry,fancyhdr,tikz,everypage}
\geometry{a4paper, right=2cm, textheight=22cm, marginparsep=0.5cm, marginparwidth=3.5cm, left=2cm, footskip=3.5cm}
\definecolor{AltisLight}{HTML}{B9BAD6}
\definecolor{AltisDark}{HTML}{05266D}
\definecolor{AltisBlue}{HTML}{1E2060}
\definecolor{IngBlue}{HTML}{162D66}
\definecolor{IngOrange}{HTML}{F25C19}
\fancyhf{}
\fancyhfoffset[L]{1cm}
\lhead{\nouppercase{\leftmark}}
\rhead{}
\lfoot{\textcolor{IngOrange}{For internal use only}}
\cfoot{\thepage}
\pagestyle{fancy}
% FONTS
\usepackage{fontspec,xunicode,xltxtra}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont [Ligatures={Common}, Numbers={Lining}]{Linux Libertine O}
% ---- MARGIN LABELS
\usepackage{marginnote}
\newcommand{\sidetag}[1]{\noindent{\parindent=0pt\marginnote{\scriptsize #1}}}
\renewcommand*{\raggedleftmarginnote}{}
\setlength{\marginparsep}{-3.5cm}
\reversemarginpar
% HEADINGS
\usepackage{sectsty}
\usepackage[normalem]{ulem}
\sectionfont{\mdseries\upshape\Large}
\subsectionfont{\mdseries\scshape\normalsize}
\subsubsectionfont{\mdseries\upshape\small}
% BULLET LISTS
\usepackage{enumitem}
\setitemize{topsep=0pt,partopsep=0pt,parsep=0pt,itemsep=0pt}
\setdescription{topsep=0pt,partopsep=0pt,parsep=0pt,itemsep=0pt,labelwidth=1cm}
% DOCUMENT
\begin{document}
\clearpage\phantomsection\addcontentsline{toc}{section}{Robeco}\markboth{Robeco}{Robeco}%
\begin{tikzpicture}[remember picture,overlay]\node [xshift=-3cm, yshift=-5cm, scale=5]at (current page.north east) {None};\end{tikzpicture}
\section*{Score Card}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Fund name}Robeco
\end{description}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Analyst}LB
\end{description}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Period}2013 Q1
\end{description}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Last update}20130305
\end{description}\section*{Governance - Corporate}\noindent\begin{description}\item[1/2]\subsubsection*{Vivamus interdum}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam ultrices mollis posuere. Vivamus interdum, velit nec mollis dapibus,
mauris turpis posuere velit, aliquam porttitor felis dolor sed lorem.
Vivamus ac lectus ut sapien sodales lacinia. Praesent eleifend erat vel
mi placerat sit amet gravida ligula cursus. Donec volutpat consequat est
eu consequat. Etiam sit amet facilisis dui. Ut tempus laoreet sodales.
\end{description}\begin{description}\item[2/2]\subsubsection*{Donec volutpat consequat}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam ultrices mollis posuere. Vivamus interdum, velit nec mollis dapibus,
mauris turpis posuere velit, aliquam porttitor felis dolor sed lorem.
Vivamus ac lectus ut sapien sodales lacinia. Praesent eleifend erat vel
mi placerat sit amet gravida ligula cursus. Donec volutpat consequat est
eu consequat. Etiam sit amet facilisis dui. Ut tempus laoreet sodales.
\end{description}\begin{description}\item[2/2]\subsubsection*{ velit nec mollis dapibus}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam ultrices mollis posuere. Vivamus interdum, velit nec mollis dapibus,
mauris turpis posuere velit, aliquam porttitor felis dolor sed lorem.
Vivamus ac lectus ut sapien sodales lacinia. Praesent eleifend erat vel
mi placerat sit amet gravida ligula cursus. Donec volutpat consequat est
eu consequat. Etiam sit amet facilisis dui. Ut tempus laoreet sodales.
\end{description}\begin{description}\item[1/2]\subsubsection*{Etiam sit amet facilisis dui.}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam ultrices mollis posuere. Vivamus interdum, velit nec mollis dapibus,
mauris turpis posuere velit, aliquam porttitor felis dolor sed lorem.
Vivamus ac lectus ut sapien sodales lacinia. Praesent eleifend erat vel
mi placerat sit amet gravida ligula cursus. Donec volutpat consequat est
eu consequat. Etiam sit amet facilisis dui. Ut tempus laoreet sodales.
\end{description}
\end{document}
答案1
有点难以猜测其意图(而且我没有所有的字体),但看起来主体是一个标题列表。LaTeX 有两种标记此类内容的方法,一种是作为单个项目列表,每个项目都以 开头,另一种\item
是作为标有 等的章节标题列表subsection
。您的示例混合了这两种方法。
这表明一种可能的布局是稍微修改后的描述列表,其中标签始终位于其自己的行上。我删除了一项中的文本。
\documentclass[11pt, a4paper]{article}
% DOCUMENT LAYOUT
\usepackage{geometry,fancyhdr,tikz,everypage}
\geometry{a4paper, right=2cm, textheight=22cm, marginparsep=0.5cm, marginparwidth=3.5cm, left=2cm, footskip=3.5cm}
\definecolor{AltisLight}{HTML}{B9BAD6}
\definecolor{AltisDark}{HTML}{05266D}
\definecolor{AltisBlue}{HTML}{1E2060}
\definecolor{IngBlue}{HTML}{162D66}
\definecolor{IngOrange}{HTML}{F25C19}
\fancyhf{}
\fancyhfoffset[L]{1cm}
\lhead{\nouppercase{\leftmark}}
\rhead{}
\lfoot{\textcolor{IngOrange}{For internal use only}}
\cfoot{\thepage}
\pagestyle{fancy}
% FONTS
\usepackage{fontspec,xunicode,xltxtra}
%\defaultfontfeatures{Mapping=tex-text}
%\setromanfont [Ligatures={Common}, Numbers={Lining}]{Linux Libertine O}
% ---- MARGIN LABELS
\usepackage{marginnote}
\newcommand{\sidetag}[1]{\noindent{\parindent=0pt\marginnote{\scriptsize #1}}}
\renewcommand*{\raggedleftmarginnote}{}
\setlength{\marginparsep}{-3.5cm}
\reversemarginpar
% HEADINGS
\usepackage{sectsty}
\usepackage[normalem]{ulem}
\sectionfont{\mdseries\upshape\Large}
\subsectionfont{\mdseries\scshape\normalsize}
\subsubsectionfont{\mdseries\upshape\small}
% BULLET LISTS
\usepackage{enumitem}
\setitemize{topsep=0pt,partopsep=0pt,parsep=0pt,itemsep=0pt}
\setdescription{topsep=0pt,partopsep=0pt,parsep=0pt,itemsep=0pt,labelwidth=1cm}
\makeatletter
\newenvironment{adescription}
{\list{}{\itemindent\z@
\itemsep\bigskipamount
\let\makelabel\adescriptionlabel}}
{\endlist}
\newcommand*\adescriptionlabel[1]{%
\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{\normalfont\bfseries #1}}
\makeatother
% DOCUMENT
\begin{document}
\clearpage%\phantomsection
\addcontentsline{toc}{section}{Robeco}\markboth{Robeco}{Robeco}%
\begin{tikzpicture}[remember picture,overlay]\node [xshift=-3cm, yshift=-5cm, scale=5]at (current page.north east) {None};\end{tikzpicture}
\section*{Score Card}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Fund name}Robeco
\end{description}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Analyst}LB
\end{description}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Period}2013 Q1
\end{description}\begin{description}[leftmargin=2.4cm]\item[]\sidetag{Last update}20130305
\end{description}
\section*{Governance - Corporate}
\begin{adescription}
\item[1/2 Vivamus interdum]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam ultrices mollis posuere. Vivamus interdum, velit nec mollis dapibus,
mauris turpis posuere velit, aliquam porttitor felis dolor sed lorem.
Vivamus ac lectus ut sapien sodales lacinia. Praesent eleifend erat vel
mi placerat sit amet gravida ligula cursus. Donec volutpat consequat est
eu consequat. Etiam sit amet facilisis dui. Ut tempus laoreet sodales.
\item[2/2 Donec volutpat consequat]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam ultrices mollis posuere. Vivamus interdum, velit nec mollis dapibus,
mauris turpis posuere velit, aliquam porttitor felis dolor sed lorem.
Vivamus ac lectus ut sapien sodales lacinia. Praesent eleifend erat vel
mi placerat sit amet gravida ligula cursus. Donec volutpat consequat est
eu consequat. Etiam sit amet facilisis dui. Ut tempus laoreet sodales.
\item[2/2 velit nec mollis dapibus]
% nothing here
\item[1/2 Etiam sit amet facilisis dui.]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nullam ultrices mollis posuere. Vivamus interdum, velit nec mollis dapibus,
mauris turpis posuere velit, aliquam porttitor felis dolor sed lorem.
Vivamus ac lectus ut sapien sodales lacinia. Praesent eleifend erat vel
mi placerat sit amet gravida ligula cursus. Donec volutpat consequat est
eu consequat. Etiam sit amet facilisis dui. Ut tempus laoreet sodales.
\end{adescription}
\end{document}