两列?项目之间带有箭头的列表

两列?项目之间带有箭头的列表

如何实现像这样的两列列表:

在此处输入图片描述

我只希望列表项目符号在左侧,所以实际上如果每个条目都是单个项目,那就没问题。项目永远不会跨越多行。我尝试过使用对齐块和两列列表,但没有任何效果。

答案1

TeX 提供了一个\rightarrowfill可以完成此操作的命令。它是纯 TeX 和 LaTeX 的标准部分。

\documentclass{article}
\newcommand{\abox}[2]{\makebox[#1][l]{#2 \rightarrowfill}}    
\begin{document}
\begin{itemize}
    \item \abox{1in}{Item 1} Explanation 1
    \item \abox{1in}{Item 2} Explanation 2
    \item \abox{1in}{Item 3} Explanation 3
    \item \abox{1in}{Last item} Last explanation
\end{itemize}
\end{document}

在此处输入图片描述

如果您想要“更漂亮”的箭头,只需添加\usepackage{mathabx}或重新定义\rightarrow您最喜欢的箭头符号即可。这是有效的,因为\rightarrrowfill使用了 的当前定义\rightarrow

还有一个相应的\leftarrowfill命令。

如果您想不使用 LaTeX 来使用该命令,也可以使用普通的 TeX 工具来定义该命令:

\def\abox#1#2{\leavevmode\hbox to #1{#2\ \rightarrowfill}}

另一种方法,如果你有很长的解释,可能会更好,那就是创建一个使用 的新列表环境\rightarrowfill。例如

\documentclass{article}
\usepackage{mathabx}
\usepackage{calc} % needed to use + in \setlength
\newenvironment{arrowlist}[1][1in]%
 {\begin{list}{}{%
   \renewcommand{\makelabel}[1]{\indent\textbullet\ \textit{##1}\ \rightarrowfill}%
   \setlength{\labelwidth}{#1}%
   \setlength{\leftmargin}{\labelwidth+\labelsep}%
   }}
{\end{list}}
\begin{document}

\begin{arrowlist}
  \item[First thing] Explanation 1 
  \item[Second one] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
    Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. 
    Curabitur dictum gravida mauris.
\end{arrowlist}

Or to make the labels longer than 1in...

\begin{arrowlist}[1.4in]
  \item[First thing] Explanation 1 
  \item[Second one] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
     Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
\end{arrowlist}

\end{document}

在此处输入图片描述

答案2

一种可能性是:

\documentclass{article}
\usepackage{amsmath}

\newlength\BoxWd
\newlength\TextWd
\newlength\ArrowWd
\setlength\BoxWd{9em}
\newcommand\MyItem[2]{%
  \settowidth\TextWd{#1}%
  \setlength\ArrowWd{\dimexpr\BoxWd-\TextWd\relax}%
  \makebox[\dimexpr\BoxWd+1em\relax][l]{%
    #1$\xrightarrow{\hspace*{\ArrowWd}}$%
  }\parbox[t]{\dimexpr\linewidth-\BoxWd-1em\relax}{#2}%
}

\begin{document}

\begin{itemize}
\item\MyItem{Some text.}{A little description.}
\item\MyItem{Some other text.}{A little description.}
\item\MyItem{Text.}{A longer description. The text now will span more than one line. In fact, it will span three lines just for the example.}
\end{itemize}

\end{document}

在此处输入图片描述

语法是:

\MyItem{<item>}{<explanation>}

使用长度来控制宽度\BoxWd

答案3

我从中导入了一个隐形箭头,mathabx因为我认为它看起来比计算机现代版本更好。参数\def\arrowlength{3cm}\def\bulletskip{0.5cm}可以重置以适应。

\documentclass{article}
% Setup the matha font (from mathabx.sty)
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
      <5> <6> <7> <8> <9> <10> gen * matha
      <10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
      }{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}

% Define a subset character from that font (from mathabx.dcl)
% to completely replace the \subset character, you can replace
% \varsubset with \subset

\DeclareMathSymbol{\varrightarrow}{3}{matha}{"D1}

\usepackage{stackengine}
\usepackage{xcolor}
\def\arrowlength{3cm}
\def\bulletskip{0.5cm}
\def\rarrow#1{\mathrel{\rule[2.15pt]{#1}{0.7pt}\kern-2.5ex\varrightarrow}}
\def\aritem#1#2{\def\stacktype{L}\def\stackalignment{l}\setstackgap{L}{0pt}%
  \noindent$\bullet$\hspace{\bulletskip}%
  \stackon{$\rarrow{\arrowlength}$}{\colorbox{white}{#1}}~\textit{#2}}

\begin{document}

\aritem{Item 1}{Explanation 1}\\
\aritem{Item 2}{Explanation 2}\\
\aritem{Item 3}{Explanation 3}\\
\aritem{Last Item}{Last Explanation}\\

\end{document}

在此处输入图片描述

相关内容