我想在文档右侧添加垂直线(以指示该部分的参考资料)。我尝试使用包含longtable
整个文档的 来实现(在左列中,然后使用右列绘制线条),但如果我在 中pdflatex
放置 ,效果会不太好。有什么方法可以解决这个问题吗?\section
longtable
(我需要这个,因为我需要能够从来源重新创建大部分文档,并且我认为对来源进行直观的表示会更容易记住)
编辑:我设法得到了一些看起来像我想要的东西longtable
,但是 LaTeX 代码有点丑陋(主要是因为我必须将所有内容包装起来,minipage
否则它无法编译)。
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{longtable}
\usepackage[table]{xcolor}
\newtheoremstyle{named}{}{}{\itshape}{}{\bfseries}{}{.5em}{#1 #2. (\thmnote{#3})}
\theoremstyle{named}
\newtheorem{definition}{Definition}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\begin{document}
\title{Colored things}
\maketitle
\begin{longtable}{lllllll}
\begin{minipage}{\textwidth}\section{Red things}\end{minipage} & & \cellcolor{pink} & & & &\\
& & \cellcolor{pink} & & & &\\
\begin{minipage}{\textwidth}\subsection{Red balls}\end{minipage} & & \cellcolor{pink} & & & &\\
& & \cellcolor{pink} & & & &\\
\begin{minipage}{\textwidth}\begin{definition}[Red ball] Red balls are balls that are red.\end{definition}\end{minipage} & & \cellcolor{pink} & & & &\\
& & \cellcolor{pink} & & & &\\
\begin{minipage}{\textwidth}\begin{theorem}Red balls are not blue.\end{theorem}\end{minipage} & & \cellcolor{pink} & & & &\\
& & \cellcolor{pink} & & & &\\
\begin{minipage}{\textwidth}\subsection{Red cubes}\end{minipage} & & \cellcolor{pink} & & \cellcolor{orange} & &\\
& & \cellcolor{pink} & & \cellcolor{orange} & &\\
$\vdots$ & & \cellcolor{pink} & & \cellcolor{orange} & &\\
& & \cellcolor{pink} & & \cellcolor{orange} & &\\
\begin{minipage}{\textwidth}\section{Blue things}\end{minipage} & & & & \cellcolor{orange} & &\\
& & & & \cellcolor{orange} & &\\
\begin{minipage}{\textwidth}\subsection{Blue cubes}\end{minipage} & & & & \cellcolor{orange} & &\\
& & & & \cellcolor{orange} & &\\
$\vdots$ & & & & \cellcolor{orange} & &\\
& & & & \cellcolor{orange} & &\\
\begin{minipage}{\textwidth}\subsection{Blue pyramids}\end{minipage} & & & & \cellcolor{orange} & &\\
$\vdots$ & & & & \cellcolor{orange} & &\\
& & & & & &\\
\begin{minipage}{\textwidth}\section{Green things}\end{minipage} & & & & & &\\
& & & & & &\\
\begin{minipage}{\textwidth}\subsection{Green balls}\end{minipage} & & & & & & \cellcolor{yellow}\\
& & & & & & \cellcolor{yellow}\\
$\vdots$ & & & & & & \cellcolor{yellow}\\
& & & & & &\\
\begin{minipage}{\textwidth}\subsection{Green pyramids}\end{minipage} & & & & \cellcolor{orange} & &\\
& & & & \cellcolor{orange} & &\\
$\vdots$ & & & & \cellcolor{orange} & &\\
& & & & \cellcolor{orange} & &\\
\end{longtable}
\section*{References}
[1] Everything about red things, Someone \textcolor{pink}{\rule{0.3cm}{0.3cm}}\newline
[2] Everything about cubes and pyramids, Someone else \textcolor{orange}{\rule{0.3cm}{0.3cm}}\newline
[3] The theory of green balls, Yet another person \textcolor{yellow}{\rule{0.3cm}{0.3cm}}
\end{document}
答案1
可以明确地绘制彩色条纹,例如像这样:
\documentclass[a4paper,14pt]{extarticle}
\usepackage[absolute, overlay]{textpos}
\usepackage{tikz}
\newcommand{\markline}[4]{
% #1 -- x position
% #2 -- y position
% #3 -- length of the stripe
% #4 -- color of the stripe
\begin{textblock}{1}(#1,#2)
\tikz \fill [#4] (0,0) rectangle (0.25,#3);
\end{textblock}
}
\begin{document}
\begin{enumerate}
\item One
\item Two
\item Three
\item Four
\item Five
\item Six
\item Seven
\item Eight
\item Nine
\item Ten
\end{enumerate}
\markline{6}{2.4}{2}{orange}
\markline{6.25}{2.94}{2}{blue}
\markline{6}{4.02}{3}{orange}
\markline{6.5}{4.6}{6}{green}
\end{document}
然而,在这种形式下,如果标记文本的位置发生变化,它们不会自动移动。