# Centering a line of text vertically

I have a piece of text (to be precise, a chapter heading) that is preceded and followed by a rule. The code looks as follows:

\documentclass[a4paper, 12pt]{book}
\usepackage{titlesec}

\begin{document}
\noindent\rule[\baselineskip]{6cm}{.4pt}\\
\rule[\baselineskip]{6cm}{.4pt}

\titleformat{\chapter}[block]{}{}{0pt}
{%
{\large\MakeUppercase\thechapter\\}
\hrule
\vspace{\baselineskip}
\hbox{\LARGE\bfseries}
}
[\LARGE\vspace{\baselineskip}\hrule]

\chapter{Test}

\end{document}


which yields

Now - I want the white space above and below the text to be of equal size, which can be achieved by centering the text vertically in the "space" that is reserved for the line it is in (so basically, I want to lift the text a little bit from its baseline).

How can I do this? I've been fiddling around with boxes (especially \raisebox seems promising), but I get confused by how they work and have not managed to get exactly what I want. I am looking for the most simple solution.

EDIT: David Carlisle's solution works in the running text, but I actually want to use it in the \titleformat (from the titlesec package) command. The updated example would look something like this (I am aware that I can use \thechapter in the \titleformat's "label" field, but there is a reason why I am not doing that):

\documentclass[a4paper, 12pt]{book}
\usepackage{titlesec}

\begin{document}
\titleformat{\chapter}[block]{}{}{0pt}
{%
{\large\MakeUppercase\thechapter\\}
\hrule
\vspace{\baselineskip}
\hbox{\LARGE\bfseries}
}
[\LARGE\vspace{\baselineskip}\hrule]

% The chapter header is not as I want it, but in the running text this works:
\noindent\rule[\baselineskip]{6cm}{.4pt}\\
\rule[\baselineskip]{6cm}{.4pt}

\end{document}


... but now I get two new problems:

(1) The text is neither bold nor \LARGE
(2) The text is not centered vertically between the lines

Is what I want even possible?

• Please post a complete compilable document, with documentclass and minimal text (as above). That makes it easier for folks here to grab the code and help you fix it. – Ethan Bolker Dec 18 '15 at 13:48

Probably easier to use the primitives here

\documentclass{article}

\begin{document}
\showoutput

\hrule
\hrule

\bigskip

\hrule
\vskip5pt
\vskip5pt
\hrule

\end{document}


\vspace should do the job. Here below the complete example on top of your code, you can customize the vertical space that suits you, here 2cm used:

\documentclass{article}
\begin{document}
\noindent\rule[\baselineskip]{6cm}{.4pt}
\vspace{2cm}


Notice that the blank line after the \vspace is on purpose.
• don't tell @egreg you used \vspace ;) – Rico Dec 18 '15 at 14:49
• @Rico Why not? I'd avoid \\ followed by \vspace, of course. – egreg Dec 18 '15 at 21:38