2

How can I do something like \noindent\rule{\linewidth}{0.25mm} but in a way that doesn't leave a big gap before it? Currently it's kind of like \bottomrule, almost as if it skips a line. I want it to be more like \midrule, so it runs through the middle of where the text would usually be. It's not a table or tabular environment, so I can't really use those.

I'm using it to create strong visible separators between three distinct stanzas, paragraphs, or similar text blocks. I wouldn't usually do so, but it's a special situation.

Here's a comparison. Looking at them now, neither are really what I want. I want them to be a bit of each. So, usually theres a blank line between two paragraphs, right? Well i want to draw a line directly down the middle of that empty line. So the gap is symmetrically divided. I know it's a tiny thing, but with a word processor it would be relatively simple adjustment.

\documentclass{article}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{lipsum}

\begin{document}

    \section{I'm a Heading}
    \lipsum[1-1]
    $$i^{(m)} = \frac{A_n}{\sum{q(uation)}}$$
    \noindent\rule{\linewidth}{0.25mm}
    \lipsum[2-2]
    \noindent\rule{\linewidth}{0.25mm}
    \lipsum[3-3]
    \noindent\rule{\linewidth}{0.25mm}
    \lipsum[4-4]
    \noindent\rule{\linewidth}{0.25mm}

\end{document}

enter image description here


\documentclass{article}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{lipsum}

\begin{document}

    \section{I'm a Heading}
    \lipsum[1-1]
    $$i^{(m)} = \frac{A_n}{\sum{q(uation)}}$$
    \noindent\toprule
    \lipsum[2-2]
    \noindent\midrule
    \lipsum[3-3]
    \noindent\midrule
    \lipsum[4-4]
    \noindent\bottomrule

\end{document}

enter image description here

  • 5
    please make a MWE – muxoveji May 23 at 19:01
  • There, you can have two. – voices May 23 at 20:15
2

You can use vcenter to make sure the rule is perfectly centered on the center-line rather than the baseline and use an \hrule of height 0.25mm.

\documentclass[12pt,a4paper]{article}
\usepackage{enumitem}

\newcommand\separator{\par\vskip-\lastskip\noindent$\vcenter{\hfil\hrule height .25mm}$\par}

\begin{document}

Some paragraph ..
\separator
Some other paragraph ..

Now with \verb|enumerate|:
\begin{enumerate}
\item First item 
\item Second item
\item Third item
\end{enumerate}
\separator
\begin{enumerate}[topsep=0pt]
\item First item 
\item Second item
\item Third item
\end{enumerate}

\end{document}

enter image description here

  • I think this might be it. what are the $ for? Can you explain how that works please? Can I use it without defining a new command too? – voices May 23 at 20:22
  • Damn. Doesn't work after using \enumerate. – voices May 23 at 20:27
  • 1
    I've added an example with enumerate. enumerate adds space above and below itself, to remove the space above use [topsep=0pt] after loading the enumitem package and to remove the space below, add \vskip-\lastskip to the macro you created. – AboAmmar May 23 at 21:01
1

You can adjust the 6pt and -7pt to suit.

\documentclass{article}
\newcommand\myline{\par\noindent\rule[6pt]{\linewidth}{0.25mm}\vspace{-7pt}\par}
\begin{document}
This(g)

\myline
That

\myline

The other
\end{document}

enter image description here

  • That's what I use currently. I should have mentioned that. The problem is it seems kind of hacky and it causes problems when rearranging a final document, especially where floats are concerned. It's a real nightmare. Also, you kind of have to adjust it and recompile until you get it right. Plus it's hard to get the dimensions perfect and all that. – voices May 23 at 19:19
  • @tjt263 Without an MWE on your part, it is awful difficult to figure that out. – Steven B. Segletes May 23 at 19:23

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.