4

i'd like to write words that fit between two lines.

i found the following code:

\documentclass[parskip,paper=a4]{scrartcl}
\usepackage{calc}

\setlength{\parindent}{0pt}
\setlength{\fboxsep}{0pt}
\pagestyle{empty}

\newsavebox{\mybox}
\newenvironment{mb}
{\begin{lrbox}{\mybox}\begin{minipage}[4mm]{\columnwidth-2\fboxsep}}%
{\end{minipage}\end{lrbox}\par\vspace{10mm}\noindent\fbox{\usebox{\mybox}}\par}

\begin{document}
\begin{mb}
\Huge Stackexchange
\end{mb}
\end{document}

what i like to get is something like this:

edit: to be more clear ... sorry!

i'd like the lines to be the full width of the page with only some characters in front of the two lines.

5

The following example puts the text in a box, then it reduces the height and depth to put a frame (\fbox) without margin around the shrinked box. The original height and depth is kept by \vphantom.

\documentclass[parskip,paper=a4]{scrartcl}

\newcommand*{\TwoLinesBox}[1]{%
  \leavevmode
  \begingroup
    \sbox0{\,#1\,}%
    \vphantom{\copy0}% keep original height and depth
    \sbox2{x}% new height
    \ht0=\ht2 %
    \dp0=0pt %
    \setlength{\fboxsep}{0pt}% \fbox without additional inner margins
    \fbox{\copy0}%
  \endgroup
}

\begin{document}
\Huge
\noindent
\TwoLinesBox{Stackexchange}
\end{document}

Result

Half open box, spanning the line

The following example uses a tabular environment with one column that spans the whole line width. The two lines are set at the beginning of the row.

The code uses plain TeX macros and primitives. Literature:

The example file:

\documentclass{article}

\usepackage{array}

\newenvironment{twolines}{%
  \par
  \noindent
  \begin{tabular}{@{}>{\AddTwoLines}p{\linewidth}@{}}%
}{%
  \end{tabular}%
}

\newcommand*{\AddTwoLines}{%
  \noindent
  \sbox0{\vrule\vphantom{x}}%
  \rlap{%
    \vbox{\hrule width\linewidth}%
  }%
  \rlap{%
    \raise\ht0\vbox{\hrule width\linewidth}%
  }%
  \copy0 %
  \,\ignorespaces
}

\begin{document}
\Huge
\begin{twolines}
  Stack\\
  Exchange
\end{twolines}
\end{document}

Result

  • thanx! that is nearly that what i want to get! but how can i make the lines to be full width of the page? do you have a reference for sbox0, sbox2, ht0, ht2 ... i haven't found anything how to use this to modify your example. – UweThom Oct 19 '12 at 7:58
  • ok ... once again my fault :( but how can i add a vertical "|" at the end? i left it in my example to visualize that the end of the two lines is not the end ... – UweThom Oct 19 '12 at 17:08

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.