我需要近似于以下格式的文档,其中列表在同一行的单词或短语之后开始:
word or phrase source language 1) First translated definition
- Example phrase with word in source language
Example phrase translation to target
- Another source example
Another target translation
2) Second translated definition
我对 lyx 或 latex 完全陌生。在摆弄了列表之后,我想我应该能够弄清楚如何缩进列表并创建嵌套列表。我应该研究文本框、选项卡、表格还是列来实现这一点?我是否必须为这种格式创建自己的“环境”?或者我可以找到一个可以做到这一点的模板吗?非常感谢任何指点。
答案1
根据 Steven Segletes 的评论,我建议您在 tabularx 环境的右侧列中采用双列tabularx
环境和定制的enumerate
和itemize
环境(在下面的代码中命名为myenumerate
和)。myitemize
关于此设置的两点说明:
在右侧列的第一级(枚举)和第二级(逐项)列表环境中允许换行。
左侧列也允许换行。如果不允许,只需将其替换
P{3cm}
为即可l
。
\documentclass{article}
\usepackage{tabularx,enumitem,ragged2e}
% Automatic line breaking and hanging indentation in 1st col.:
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash%
\hangafter=1\hangindent=1em}p{#1}}
% Define custom enumerated and itemized list environments:
\newlist{myenumerate}{enumerate}{1}
\setlist[myenumerate,1]{nosep,wide=0pt,label=\arabic*),
before=\begin{minipage}[t]{\hsize},
after =\end{minipage}}
\newlist{myitemize}{itemize}{1}
\setlist[myitemize,1]{noitemsep,label=-}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{} P{3cm} X @{}}
Word or phrase source language &
\begin{myenumerate}
\item First translated definition
\begin{myitemize}
\item Example phrase with word in source language
Example phrase translation in target
\item Another source example
Another target translation
\end{myitemize}
\item Second translated definition
\begin{myitemize}
\item bla bla bla
\item ble ble blie
\end{myitemize}
\end{myenumerate} \\
\end{tabularx}
\end{document}
答案2
indentation
我建议基于 LaTeX 列表系统构建环境。环境的参数indentation
是左侧文本的元素。您可以将 LateX 列表放在环境主体中。
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentEnvironment { indentation } { m }
{
\hbox_set:Nn \l_tmpa_box { #1 }
\box_set_dp:Nn \l_tmpa_box \c_zero_dim
\dim_set:Nn \l_tmpa_dim { \box_wd:N \l_tmpa_box }
\begin { list }
{
\hspace { \labelsep }
\box_use:N \l_tmpa_box
\hspace { - \labelsep }
}
{
\dim_set:Nn \leftmargin \l_tmpa_dim
\dim_set:Nn \itemindent { - \leftmargin }
\dim_zero:N \labelwidth
}
\item \scan_stop:
}
{ \end { list } }
\ExplSyntaxOff
\begin{document}
\begin{indentation}{word or phrase source }
\begin{itemize}
\item First translated definition
\begin{itemize}
\item Example phrase with word in source language
Example phrase translation to target
\item Another source example
Another target translation
\end{itemize}
\item Second translated definition
\end{itemize}
\end{indentation}
\end{document}