3

I want to draw a horizontal line in a LATEX file. The starting point is at the middle of the page and the length is the half of the paperwidth.

How can this be done? Thanks for your help.

3

This revised version works with documentclasses that have symmetric or skewed margins. I interpreted "middle of the page" to mean "middle of the paper", and not "middle of the textblock".

\documentclass{book}
\usepackage{lipsum}
\begin{document}
\noindent\kern.5\paperwidth\kern-1in\kern-\hoffset\kern-\oddsidemargin%
  \makebox[0pt][l]{\makebox[.5\paperwidth]{\hrulefill}}\par

\lipsum[3]
\end{document}

BOOK:

enter image description here

ARTICLE:

enter image description here

|improve this answer|||||
  • (My understanding of the question) Wouldn't \centerline{\hspace{0.5\textwidth}\makebox[.5\paperwidth]{\hrulefill}} be closer to the OP's request ? – BambOo Aug 21 '18 at 13:13
  • Thank you for your reply but i want the starting point of the line to be at center of the page. Obviously in your solution the starting point of the line is not at the center of the page. – Apostolos K Aug 21 '18 at 13:14
  • @ApostolosK Sorry. I will revise. – Steven B. Segletes Aug 21 '18 at 13:15
  • @ApostolosK Please see revision. – Steven B. Segletes Aug 21 '18 at 13:21
  • 3
    @ApostolosK That is not the question you asked. Which it is why it is the site policy that your question should be accompanied by a small self-contained code (starting with \documentclass, etc.) that demonstrates the problem. – Steven B. Segletes Aug 21 '18 at 13:34
1
\documentclass[twocolumn]{article}
\usepackage{tikz,lipsum}
\begin{document}

\lipsum[1-4]    
\noindent%
\tikz[remember picture,overlay]{\draw(0,0)coordinate(o)--(o -| current page.east);}

New line here

\end{document}

enter image description here

|improve this answer|||||

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.