1
\documentclass{article}

\begin{document}

\hrule

\noindent\rule{\textwidth}{0.4mm}

\noindent\rule{\textwidth}{0.4pt}

\end{document}

I need to insert text inside the rule.

4
  • \noindent\rule{\textwidth}{0.4mm} text between rules\par \noindent\rule[1ex]{\textwidth}{0.4pt} ?
    – Zarko
    Commented Nov 1, 2016 at 20:14
  • Is this different from you other request?
    – Werner
    Commented Nov 1, 2016 at 20:24
  • 1
    Do you want text to be written within the rule? If you're using a rule of thickness/width 0.4mm, the text will be quite small. Or do you just want the text written with rules above and below?
    – Werner
    Commented Nov 1, 2016 at 20:28
  • @Werner This was my first vision: characters 0.2 pt tall. :-) Commented Nov 1, 2016 at 20:37

1 Answer 1

3

Unless I've completely misunderstood the problem, here's a version that inserts text into a "rule" by using a \colorbox of appropriate width instead of an actual LaTeX rule:

\documentclass{article}

\usepackage{lipsum}
\usepackage{xcolor}

\newcommand\rulebox[1]{%
    \begingroup
    \fontsize{5}{5}\selectfont
    \fboxsep0.5pt%
    \colorbox{black}{\makebox[\linewidth][c]{\textcolor{black!80}{#1}}}%
    \endgroup
}

\begin{document}

\lipsum[1]

\noindent\rulebox{Some hidden text here}

\end{document}

enter image description here

With a higher magnification, the hidden message (if that was intended) becomes readable:

enter image description here

You must log in to answer this question.

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