1

I am trying to print two horizontal lines to look like a divider in an older book. Using \hrule with slightly different widths and lengths makes the lines look hand laid.

But trying to use \moveleft or \nointerlineskip suggested in centered hrule I get an error saying it cant be done in horizontal mode. The question hrule with indents is similar, but if so, I can't figure out how to apply the information. I get errors with \indent and \item, etc.

I'd like to understand how to fix \hrule, but answer using rule or some other command would be fine, too.

This is the code I am using, and it compiles, but every attempted adjustment leads to noncompiling.

\documentclass{scrartcl}
    %\usepackage{fontspec}
    %\setmainfont{Gentium Plus}
    %\usepackage{microtype}
\begin{document}
\begin{center}
    \normalfont\large Some Text Above 
    \vspace{9pt}
    \hrule height .8pt width .870\textwidth
    \vspace{14pt}
    \hrule height 1.1pt width .877\textwidth
    \vspace{6pt}
    1 6 4 7.
\end{center}
\end{document}

2 Answers 2

2

The problem with \rule and \leavevmode is the accumulation of \baselineskip between each baseline. In this solution, you can remove all the 0pt terms and see that they line up precisely.

\documentclass{scrartcl}
    %\usepackage{fontspec}
    %\setmainfont{Gentium Plus}% Please don't make me download another font
    %\usepackage{microtype}
\begin{document}
\begin{center}
    \normalfont\large Some Text Above 
    \hrule height 0pt
    \vrule height 9pt width 0pt
    \vbox{\hrule height .8pt width .870\textwidth}
    \hrule height 0pt
    \vrule height 14pt width 0pt
    \vbox{\hrule height 1.1pt width .877\textwidth}
    \hrule height 0pt
    \vrule height 6pt width 0pt
    \hrule height 0pt
    1 6 4 7.
\end{center}
\end{document}
3
  • This way I will also set the \parskip to 0pt inside the center environment. Otherwise any previous setting of this length could ruin your work with the invisible rules.
    – Fran
    Oct 3, 2018 at 12:44
  • This is almost exactly what I want; and your response made it easy for me to adjust parameters and see their affect---especially to visualize what vrule does. (+1) If possible I would like the two lines to look as if they were intended to be the same length (though one is slightly longer than the other), but didn't quite match when laid by hand. Is it possible for the lines to begin at the same horizontal location but end at slightly different horizontal locations rather than being exactly centered?
    – Bryan H-M
    Oct 3, 2018 at 16:40
  • That is why I added a \hrule height 0pt after each \vbox{...}. Oct 3, 2018 at 19:05
2

Use rule instead of \hrule:

mwe

\documentclass{scrartcl}
\begin{document}
\begin{center}
    \large Some Text Above\\     
    \rule[1ex]{.8\textwidth}{1pt}\\
    \rule[1.9ex]{.7\textwidth}{.6pt}\\[-6pt]
    1 6 4 7
\end{center}
\end{document}

Whit \hrule is also possible but unnecessary more complex:

\documentclass{scrartcl}
\begin{document}
{\centering
\large Some Text Above\\[-4pt] 
\leavevmode\vbox{\hrule height 1pt width .8\textwidth}\\[-4pt] 
\leavevmode\vbox{\hrule  width .7\textwidth}\\ 
1 6 4 7\par}

\end{document}
3
  • Thank you for contrasting rule and hrule. This was helpful. (+1) Ideally, I would like the two lines to have the same horizontal offset rather than be perfectly centered. Any suggestions?
    – Bryan H-M
    Oct 3, 2018 at 16:42
  • @BryanM-H Without centering the lines, some like \hspace*{2cm}\rule.... or \hspace*{2cm}\vbox{\hrule ... should work.
    – Fran
    Oct 3, 2018 at 17:46
  • @BryanM-H You can also simply set a \parindent2cm and then simple write the rules separeted with blank lines (=\par), i.e., {\parindent2cm\par\rule[...]{...}{...}\par\rule[...]{...}{...}\par}. Of course without centering that part.
    – Fran
    Oct 3, 2018 at 18:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .