在制表符环境中使用时小页面后的自动垂直间距

在制表符环境中使用时小页面后的自动垂直间距

minipage我在使用该软件包与制表符选项结合时遇到了一些问题。

为了清楚起见,我提供了一个 MWE:

\documentclass[10pt, a4paper]{article}
\usepackage{multicol}
\newcommand{\ntab}[2]{
    \rlap{}\hspace{.18\textwidth}
    \llap{#1}\hspace{.02\textwidth}
    \rlap{\begin{minipage}[t]{0.27\textwidth}#2\end{minipage}}
}

\begin{document}
\begin{multicols}{2}
Safety\\
\ntab{R38:}{Irritating to skin.}\\
\ntab{R48/20/22:}{Harmful: danger of serious damage to health by prolonged exposure through inhalation and if swallowed.}\\
\ntab{S36/37:}{Wear suitable protective clothing and gloves.}\\
\ntab{R65:}{Harmful: May cause lung damage if swallowed.} \\
\ntab{R67:}{Vapors may cause drowsiness and dizziness.} \\
\ntab{R62:}{Possible risk of impaired fertility.} \\
\ntab{S16:}{Keep away from sources of ignition - No smoking.} \\
\ntab{S29:}{Do not empty into drains.} \\
\ntab{S33:}{Take precautionary measures against static discharges.} \\
\end{multicols}
\end{document}

在此处输入图片描述

看起来minipage环境内的线条显示正确,但是小页面之间的间距不正确并导致混淆。

我决定使用minipage能够在多行上书写,因为如果句子太长,就不会断行rlapllap

也许有更简单的方法可以实现这一点。

我愿意接受所有建议。

答案1

我仍然不明白您考虑的是哪种垂直间距...因此,根据我的猜测,我建议使用列表,该列表会注意项目之间的间距。例如:

\documentclass[10pt,a4paper]{article}
    \usepackage{multicol}
%\newcommand{\ntab}[2]{
%    \rlap{}\hspace{.18\textwidth}
%    \llap{#1}\hspace{.02\textwidth}
%    \rlap{\begin{minipage}[t]{0.27\textwidth}#2\end{minipage}}
%}
%    \setlength{\columnsep}{1em}

    \usepackage{calc}
    \usepackage{ragged2e}
\newcommand{\entrylabel}[1]{%
     \makebox[\labelwidth][l]{\parbox[t]{\labelwidth}{%
                                         \raggedleft\textsf{#1}}
                               }% end of makebox
                            }% end of definition
\newenvironment{entry}[1]%
    {\begin{list}{}{%
        \renewcommand{\makelabel}{\entrylabel}%
        \settowidth{\labelwidth}{\textsf{#1:~}}%
        \setlength{\leftmargin}{\labelwidth + \labelsep}
        \setlength{\listparindent}{2ex}%
        \setlength{\parsep}{0.2\baselineskip}
        \setlength{\itemsep}{0.2\baselineskip}
    }}%
    {\end{list}}

    \begin{document}
\subsection*{Safety}
\begin{multicols}{2}
    \begin{entry}{R48/20/22}\RaggedRight
\item[R38]    Irritating to skin.
\item[R48/20/22]    Harmful: danger of serious damage to health by prolonged exposure through inhalation and if swallowed.
\item[S36/37]       Wear suitable protective clothing and gloves.
\item[R65]    Harmful: May cause lung damage if swallowed.
\item[R67]    Vapors may cause drowsiness and dizziness.
\item[R62]    Possible risk of impaired fertility.
\item[S16]    Keep away from sources of ignition - No smoking.
\item[S29]    Do not empty into drains.
\item[S33]    Take precautionary measures against static discharges.
    \end{entry}
\end{multicols}
    \end{document}

这使: 在此处输入图片描述

如果您希望将“安全”作为两列文本中的普通文本,则只需将其删除\subsection{...}并移动到列表之前的两列内。

答案2

你可以看看如何在使用 minipages (或 \parboxes) 时保持恒定的 baselineskip?

\rlap如果\llap您不知道它们如何工作(并且从代码判断您不知道),请不要使用:您将会遇到非常意外的行为。

\documentclass[10pt, a4paper]{article}
\usepackage{multicol}
\newcommand{\ntab}[2]{%
  \par\noindent
  \makebox[.2\textwidth][r]{#1\hspace{.02\textwidth}}%
  \begin{minipage}[t]{0.27\textwidth}
  \raggedright
  #2\par\xdef\tpd{\the\prevdepth}\end{minipage}\par
  \prevdepth\tpd\relax
}

\begin{document}
\begin{multicols}{2}
Safety
\ntab{R38:}{Irritating to skin.}
\ntab{R48/20/22:}{Harmful: danger of serious damage to health by prolonged exposure through inhalation and if swallowed.}
\ntab{S36/37:}{Wear suitable protective clothing and gloves.}
\ntab{R65:}{Harmful: May cause lung damage if swallowed.}
\ntab{R67:}{Vapors may cause drowsiness and dizziness.}
\ntab{R62:}{Possible risk of impaired fertility.}
\ntab{S16:}{Keep away from sources of ignition - No smoking.}
\ntab{S29:}{Do not empty into drains.}
\ntab{S33:}{Take precautionary measures against static discharges.}
\end{multicols}
\end{document}

我添加了\raggedright小页面,否则排版会很糟糕。

在此处输入图片描述

答案3

您可以尝试p表格选项:

\usepackage{array}
\newcommand{\ntab}[2]{
   \begin{tabular}{>{\raggedleft}m{0.18\textwidth}p{0.27\textwidth}}
    #1 & #2
    \end{tabular}
}

相关内容