TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add a frame around a text which would be centered and vertically aligned to the middle of the box but I can only center the text.

What should I do to align the text to the middle of the box?



\noindent\fbox{\parbox{\linewidth\fboxrule\fboxsep}{\center\textbf{my text here}}}

share|improve this question
I am not sure I understand the question \fbox{{\parbox{.5\linewidth}{\centering\rule{1cm}{2cm}}}} looks vertically aligned to me. Did you take into account the y descender of the my text here in asserting the vertical centering? – jfbu Dec 2 '12 at 22:40
It depends on what you type, I had something else written in it and it was not vertically centered. There was more space at the top of it. – esmitex Dec 3 '12 at 0:22
up vote 3 down vote accepted

Does this do what you want?



    \centering\textbf{my text here}


enter image description here

share|improve this answer
Almost, I had to take off the "-2" because it would write "-2 -2" before my text. – esmitex Dec 2 '12 at 21:34
Did you use the calc package? That might be why -2 showed up. – A.Ellett Dec 2 '12 at 21:41
No, I didn't. I will try with it. – esmitex Dec 3 '12 at 0:20

Your Answer


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.