如何创建多条虚线

如何创建多条虚线

我想创建多条虚线,我在网上找到了这段代码

\newcommand{\Pointilles}[1][3]{%
        \multido{}{#1}{\makebox[\linewidth]{\dotfill}\\[\parskip]}
        }

问题是第一条虚线离段落中的最后一条虚线太近,需要手动添加一些垂直空间,如下所示

some text her. \\[4mm]
\Pointilles[2]

可能会导致虚线后出现垂直空间。同时我希望能够指定虚线的行距。

答案1

有多种方法可以实现您的目标。以下内容仅基于您已创建的内容:

在此处输入图片描述

\documentclass{article}
\usepackage{multido}

\newcommand{\Pointilles}[1]{%
  \par\nobreak
  \noindent\rule{0pt}{1.5\baselineskip}% Provides a larger gap between the preceding paragraph and the dots
  \multido{}{#1}{\noindent\makebox[\linewidth]{\dotfill}\endgraf}% ... dotted lines ...
  \bigskip% Gap between dots and next paragraph
}
\begin{document}

Here is some text.
\Pointilles{5}

Here is some more text.
\Pointilles{3}

Here is some final text.
\Pointilles{2}

\end{document}

对 进行微小调整\Pointilles可让您使用可调的 来拉伸内容\strut

在此处输入图片描述

\documentclass{article}
\usepackage{multido}

\newcommand{\Pointilles}[2][3]{%
  \par\nobreak
  \noindent\rule{0pt}{1.5\baselineskip}% Provides a larger gap between the preceding paragraph and the dots
  \multido{}{#2}{\noindent\makebox[\linewidth]{\rule{0pt}{#1\baselineskip}\dotfill}\endgraf}% ... dotted lines ...
  \bigskip% Gap between dots and next paragraph
}
\begin{document}

Here is some text.
\Pointilles{5}

Here is some more text.
\Pointilles[1.5]{3}

Here is some final text.
\Pointilles{2}

\end{document}

答案2

\documentclass{article}

\usepackage{ragged2e}

\usepackage{forloop}

\newcounter{loopcntr}

\newcommand{\rpt}[2][1]{\forloop{loopcntr}{0}{\value{loopcntr}<#1}{#2}}

\begin{document}

\begin{FlushLeft}
\noindent Here is some text.
\rpt[3]{\noindent\vbox spread 1cm {}\null\xleaders\hbox to 2mm {\hss . \hss}\hfill \null\newline}
\end{FlushLeft}

\begin{FlushLeft}
\noindent Here is some more text. \newline
\rpt[3]{\noindent\vbox spread 1cm {}\null\xleaders\hbox to 2mm {\hss . \hss}\hfill \null\newline}
\end{FlushLeft}

\begin{FlushLeft}
\noindent Here is some final text.\newline
\rpt[5]{\noindent\vbox spread 0.5cm {}\null\xleaders\hbox to 1mm {\hss . \hss}\hfill \null\newline}
\end{FlushLeft}

\end{document}

在此处输入图片描述

相关内容