0

I'm trying to add two horizontal lines above some text, something like this

\documentclass{scrbook}
\usepackage{blindtext}
\begin{document}
\blindtext
\vspace{20mm}
\hfill \hfill\\
\hrulefill  \hfill \hrulefill\\
Date \hfill Signature
\end{document}

Unfortunately the lines are not displayed. If I add a letter before the first \hrulefill, the lines appear, unfortunately the letter as well.

I'm using TexWorks BTW.

Is there a way to add such a line without a letter in the leftmost part of the line?

Thanks in advance for your help

  • 2
    Please complete your code snippet to a full compilable document and tell us which tex engine you are using. – Andrew Swann Nov 19 '17 at 11:27
  • Welcome to TeX.SX! You seem to be misusing \\. – egreg Nov 19 '17 at 11:59
  • What is wrong with \\ isn't that the command for a new line? – Eater of Khorneflakes Nov 19 '17 at 16:16
1
\documentclass{article}
\begin{document}
\noindent
\begin{minipage}{4cm}
\centering
\hrulefill\\
text
\end{minipage}
\hfill
\begin{minipage}{4cm}
\centering
\hrulefill\\
other text
\end{minipage}
\end{document}

enter image description here

1

You can use the amsmath package command underset and place an mbox under a line of length you determine. I made a new command called \lineover that takes two arguments. The first is the length of the line and the second is the text (or math if you use $ .. $). They are pushed to the edges of the page using the \hfill command.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\lineover}[2]{$\underset{\mbox{#2}}{\rule{#1}{1pt}}$}

\begin{document}

\noindent\lineover{4cm}{text}\hfill\lineover{4cm}{other text}

\bigskip
\noindent\lineover{1in}{$a=b$}\hfill\lineover{2in}{$a^2+b^2=c^2$}

\end{document} 

enter image description here

You can adjust the thickness of the line if you wish. I set it to 1pt.

  • Sorry, but this if far away to be a robust solution. Math mode to produce the line is not good idea. – Sigur Nov 19 '17 at 16:38
0

I found a solution myself:

\documentclass{scrbook}
\usepackage{blindtext}
\begin{document}
\blindtext
\vspace{20mm}
\hfill \hfill\\
\phantom{}\hrulefill  \hfill \hrulefill\\
Date \hfill Signature
\end{document}

Are there any reasons against this solution?

  • See other solutions. – Sigur Nov 19 '17 at 16:39
  • This will not center-justify your text. – Sandy G Nov 19 '17 at 16:40
0
\documentclass[11pt,a4paper]{report}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\vskip 2cm
\begin{flushright}
\begin{minipage}{6cm}\centering%
    \hrulefill\par%
    Name
\end{minipage}
\end{flushright}
\end{document}

enter image description here

  • This is essentially the same solution as the one @tomacs already posted. – Sandy G Nov 19 '17 at 16:43
  • @SandyG, oh, yest. I post a solution without reading the others. – Sigur Nov 19 '17 at 16:54

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.