Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Please consider the following code:

\documentclass{amsart}
\usepackage{tikz}
\begin{document}
\noindent \tikz\draw(0,0)--(\textwidth,0);
Some Text. More Text. More Text. \newline
\noindent \tikz\draw(0,0)--(\textwidth,0);
\end{document}

Below is a relevant part of the output that will explain the question:

Some Text

Question

How to reduce the space between the text and the second thin line (the lower one), so that the space between them equals the space between the first thin line (the upper one) and the text?

share|improve this question
    
What if the text contains descenders? –  egreg Sep 13 '12 at 15:48
    
@egreg I'd even then like the spaces between the first line and the upper (first) thin line and the space between the last line and the lower (second) thin line to match. Viewing pleasure would be enhanced if the space between the lines match with the spaces mentioned above. –  kan Sep 13 '12 at 15:52
    
Can you try and comment if it is what you want: \documentclass{amsart}\usepackage{tikz,lipsum}\begin{document}\noindent \tikz[overlay,baseline]\draw(0,-0.3ex)--++(\textwidth,0) (0,2ex)--++(\textwidth,0);\lipsum[1]\end{document} –  percusse Sep 13 '12 at 16:11
    
@percusse Indeed. But, with a little( very little space ) space between the rules and text. But, I am happy with the output I get from your code. –  kan Sep 13 '12 at 16:20
add comment

3 Answers

For dividing text with rules, here's a way. This doesn't ensure equal space between the rules, but the application you have in mind doesn't seem to need it.

\documentclass{article}

\newcommand{\divider}{\vskip2pt\hrule\vskip2pt}
\setlength{\parindent}{0pt}

\begin{document}
Some text

\divider

Some ptext

\divider

Some text

\divider

Some text

\end{document}

enter image description here

If you want that the rule automatically disappears at page breaks, then use

\newcommand{\divider}{%
  \vskip2pt
  \leaders\vrule width \textwidth\vskip0.4pt
  \nointerlineskip
  \vskip2pt
}
share|improve this answer
add comment

Here is a solution.

Note 1: TikZ is not necessary to get the desired result! (Thus, I suggest two solutions...)

Note 2: Look at A line of length \textwidth in TikZ

enter image description here

\documentclass[draft]{amsart}
\usepackage{tikz}

% with TikZ
\newcommand\myhline{%
  \noindent\tikz[baseline=-.35em]\draw(0,0)--(\linewidth-\pgflinewidth,0);\par%
}

% without TikZ
\newcommand\myhlinewotikz{%
  \noindent\rule[.35em]{\linewidth}{.4pt}\par%
}

\begin{document}

\myhline
Some Text. More Text. More Text. \par
\myhline
abc def ghi jkl mno pqr stu vwx yz. \par
\myhline

{
  \LARGE\myhline
  Some Text. More Text. More Text. \par
  \myhline
  abc def ghi jkl mno pqr stu vwx yz. \par
  \myhline
}

\myhlinewotikz
Some Text. More Text. More Text. \par
\myhlinewotikz
abc def ghi jkl mno pqr stu vwx yz. \par
\myhlinewotikz

{
  \LARGE\myhlinewotikz
  Some Text. More Text. More Text. \par
  \myhlinewotikz
  abc def ghi jkl mno pqr stu vwx yz. \par
  \myhlinewotikz
}
\end{document}

Edit: Here is a TikZ solution with minimized vertical spaces (without TikZ, egreg's answer is perfect).

enter image description here

\documentclass{amsart}
\usepackage{tikz}

\newcommand\myhline{%
  \vskip-0.3\baselineskip%
  \noindent%
  \tikz[baseline=-.35em]%
  \draw[blue,dashed](0,0)--(\linewidth-\pgflinewidth,0);
  \vskip-0.3\baselineskip%
}

\begin{document}

\myhline
Some Text. More Text. More Text.
\myhline
abc def ghi jkl mno pqr stu vwx yz.
\myhline

{
  \LARGE\myhline
  Some Text. More Text. More Text.
  \myhline
  abc def ghi jkl mno pqr stu vwx yz.
  \myhline
}
\end{document}
share|improve this answer
    
Is it possible to minimise the space between the rules and text (perhaps so that the spacing equals the space between upper rule and the text in my picture)? –  kan Sep 13 '12 at 16:22
    
Actually, thanks for the note 2; I had asked Andrew Stacey a newbie version of that question and he added \noindent to arrive at the code which is MWE of the question you linked me to. I used this in an answer here. –  kan Sep 13 '12 at 16:30
    
@KannappanSampath With TikZ, you can use some negative vertical spaces (I'll edit my answer). Without TikZ, egreg's answer is perfect. –  Paul Gaborit Sep 13 '12 at 19:46
add comment

Position of next line is at baseline of next text row. so you need to move starting point of the second line (0,0) for some about above. For this there are more possibilities:

  1. Use

    \documentclass{amsart}
    \usepackage{tikz}
    \begin{document}
    \noindent \tikz\draw(0,0)--(\textwidth,0);
    Some Text. More Text. More Text.\newline
    \noindent \tikz[baseline=-1.2ex]\draw(0,0)--(\textwidth,0);
    \end{document}
    
  2. Instead of \newline use \\[-1.2ex]

  3. Instead \draw(0,0)--(\textwidth,0) use \draw(0,1.2ex)--++(\textwidth,0)
  4. Another possibility is to put the text between lines in node and then draw top and bottom border of the box (in this case the text must be shorter than one page ...):

    \documentclass{amsart}
    \usepackage{tikz}
    \begin{document}
    \tikz{
    \node[text width=\textwidth] (text) {
        Some Text. More Text. More Text.};
    \draw (text.north west)--(text.north east)
          (text.south west)--(text.south east);
          }
    \end{document}
    

I hope that this will somehow help you.

share|improve this answer
    
@Werner Thank you for the massive edit. I will now read it. –  kan Sep 13 '12 at 16:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.