0

I want to draw some lines with dots and line. This is my code.

\documentclass{book}
\title{Multidotfills}
\usepackage{pgffor} 
\newcommand{\foreachmultidots}[1]{\foreach \n in {1,...,#1}{\par\noindent\dotfill\par}
}
\newcommand{\foreachmultirules}[1]{
    \foreach \n in {1,...,#1}{
        \noindent\rule{\textwidth}{0.4pt}\newline
    }
}

\usepackage{forloop}
\newcounter{count}
\newcommand{\forloopmultidots}[1]{
    \forloop{count}{1}{\value{count} <#1}{
        \par\noindent\dotfill\par
    }
}
\newcommand{\forloopmultirules}[1]{
    \forloop{count}{0}{\value{count} <#1}{
        \noindent\rule{\textwidth}{0.4pt}\newline
    }
}
\begin{document}
\textbackslash usepackage\{pgffor\}
\foreachmultidots{10}
\foreachmultirules{10}

\textbackslash usepackage\{forloop\}
\forloopmultidots{10}
\forloopmultirules{10}
\end{document}

How can I increase or decrease height between of two lines like the second picture?

enter image description here

enter image description here

1
  • You can adjust \baselineskip. \setlength{\baselineskip}{\dimexpr \textheight/#2}% will fill an entire page. Jul 27 '17 at 12:19
1

You could add a second optional parameter to your commands for the height. (I changed the number of lines, so it fits on one page in the example.)

\documentclass{book}
\title{Multidotfills}
\usepackage{pgffor} 
\newcommand{\foreachmultidots}[2][0mm]{
    \vspace{#1}
    \foreach \n in {1,...,#2}{
        \par\noindent\dotfill\par\vspace{#1}
    }
}
\newcommand{\foreachmultirules}[2][0mm]{
    \vspace{#1}
    \foreach \n in {1,...,#2}{
        \noindent\rule{\textwidth}{0.4pt}\\[#1]
    }
}

\usepackage{forloop}
\newcounter{count}
\newcommand{\forloopmultidots}[2][0mm]{
    \vspace{#1}
    \forloop{count}{1}{\value{count} <#2}{
        \par\noindent\dotfill\par\vspace{#1}
    }
}
\newcommand{\forloopmultirules}[2][0mm]{
    \vspace{#1}
    \forloop{count}{0}{\value{count} <#2}{
        \noindent\rule{\textwidth}{0.4pt}\\[#1]
    }
}
\begin{document}
\noindent\verb|\usepackage{pgffor}|
\foreachmultidots{8} % no Value -> default value [0mm]
\foreachmultirules[3mm]{8} % positive Value to increse height

\noindent\verb|\usepackage{forloop}|
\forloopmultidots[-1mm]{8} % negative Value to decrese height
\forloopmultirules[2mm]{8} % positive Value to increse height
\end{document}

enter image description here

You can also use \linespread{1.25}\selectfont to set the linespread relativly to the standard globally.

1
  • May I suggest an alternative solution, namely, using a strut (that is, a zero-width, and hence invisible vertical rule) at the beginning of each line?
    – GuM
    Jul 27 '17 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.