外栏分类段落

外栏分类段落

我想写一份报告,其中外柱有助于对段落进行分类,如附图所示。蓝色文本充当一些最重要段落的“标题”。如何在 Latex 中实现这一点?这将在报告中多次使用。

在此处输入图片描述

答案1

图像上的文档片段对我来说看起来像是单列文档的片段,其中命令\marginpar用于将注释放入页边距,文本颜色为蓝色,\raggedleft左侧页面(页码为偶数)为文本,右侧\raggedright页面(页码为奇数)可能为文本。(请注意,使用\raggedleft/\raggedright时,需要确保\par在这些“开关”生效时执行该操作。)

可能是这样的——\ifthispageodd包中的命令scrextend用于检测放置边距段落的页面的页码的奇偶校验;为了应对(La)TeX 输出例程的异步性,由于这种异步性,评估页面计数器的当前值不可靠,依次在\ifthispageodd内部放置和评估引用标签,这意味着您需要至少编译文档两次,直到所有内容匹配:

\documentclass[twoside]{report}

\usepackage{scrextend}
\usepackage{color}

{\normalfont\normalsize
\expandafter}\expandafter\parskip\expandafter=\the\ht\strutbox

\parindent=0em

\begin{document}

\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  This is blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.
This is main text. This is main text. This is main text. This is main text.
\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  Blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.

\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  This is blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.
This is main text. This is main text. This is main text. This is main text.
\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  Blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.

\newpage

\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  This is blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.
This is main text. This is main text. This is main text. This is main text.
\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  Blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.

\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  This is blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.
This is main text. This is main text. This is main text. This is main text.
\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  Blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.

\newpage

\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  This is blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.
This is main text. This is main text. This is main text. This is main text.
\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  Blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.

\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  This is blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.
This is main text. This is main text. This is main text. This is main text.
\leavevmode\marginpar{%
  \begingroup
  \leavevmode
  \ifthispageodd{\raggedright}{\raggedleft}%
  \itshape
  \color{blue}%
  Blue text.%
  \par
  \endgroup
}%
This is main text. This is main text. This is main text. This is main text.

\end{document}

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

相关内容