0

I'm trying to vertically center a text in a colorbox, but everything I've tried thus far has either gotten no results or pushed my footer onto the next page.

There aren't many answers available specifically for LaTeX, and the code that I've tried to translate from HTML and CSS has not worked.

%---------------------------------------%
%   ARTIFICIAL FOOTER (fancy footer cannot exceed linewidth) 
%---------------------------------------%
\samepage
\null
\vspace*{\fill}
\hspace{-0.20\linewidth}\colorbox{complcol}{\makebox[1.5\linewidth][c]
{\mystrut \large
\textcolor{white}{555.000.0000} $\cdot$ $\cdot$  
\textcolor{white}{Nora -------} $\cdot$ $\cdot$  
\textcolor{white}{@gmail.com}
\textcolor{complcol}{\Huge{LLL}}}}

I want the text to be in the center of the colorbox, and ideally for the colorbox to be larger height-wise as well (that's what the "LLL" at the end is for)

It's a little difficult to see, but the text is vertically aligned at the bottom of the box.

norah1237
  • 37
  • 7
  • 1
    Give a minimal working example, otherwise people will not be able to reproduce the problem and to find a solution. Just a remark. Why dont you adapt the strut height (I assume it is the purpose of \mystrut) instead of adding invisible huge letters to make you box higher? It is *by far* more flexible. – Alain Merigot Jun 25 '19 at 23:10
  • Thank you! I'm a little new to LaTeX and hadn't tried that yet but it worked! @alain – norah1237 Jun 26 '19 at 17:41

1 Answers1

1

So I actually found another snippet of code related to adapting the strut height that helped me get things at least ~slightly~ more centered. I think I know how it works but someone please correct me if I am wrong...

\def\mystrut(#1,#2){\vrule height #1pt depth #2pt width 0pt}    

\hspace{-0.20\linewidth}\colorbox{complcol}{\makebox[1.5\linewidth][c]
{\mystrut(14.75,9.8) \large
\textcolor{white}{555.000.0000} $\cdot$ $\cdot$  
\textcolor{white}{Nora -------} $\cdot$ $\cdot$  
\textcolor{white}{@gmail.com}
\textcolor{complcol}}}

So the depth setting is what alters the baseline of the text, which allows me to control how vertically "centered" the text is, even if it isn't exact. Would still like to find a more exact solution though...

norah1237
  • 37
  • 7