I would like to find a way to make boxes with a colored background, that take the whole width available, with variable text size and variable arraystretch.
For the moment, the best solution I've found is to use tabularx but depending on the combination of text size and arraystretch factor, the text is often not vertically aligned.
Here is an example with 3 text size and 2 arraystretch factors :
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{tabularx}
\begin{document}
\setlength{\arrayrulewidth}{0pt} \renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}
\section{Arraystretch == 1}
\renewcommand{\arraystretch}{1}
\begin{tabularx}{\linewidth}{X} \rowcolor{lightgray} \begin{normalsize}Title\end{normalsize} \end{tabularx}
\begin{tabularx}{\linewidth}{X} \rowcolor{lightgray} \begin{Large}Title\end{Large} \end{tabularx}
\begin{tabularx}{\linewidth}{X} \rowcolor{lightgray} \begin{Huge}Title\end{Huge} \end{tabularx}
\section{Arraystretch == 1.5}
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\linewidth}{X} \rowcolor{lightgray} \begin{normalsize}Title\end{normalsize} \end{tabularx}
\begin{tabularx}{\linewidth}{X} \rowcolor{lightgray} \begin{Large}Title\end{Large} \end{tabularx}
\begin{tabularx}{\linewidth}{X} \rowcolor{lightgray} \begin{Huge}Title\end{Huge} \end{tabularx}
\end{document}
In this example, the first 3 tabularx are not vertically aligned, the text touches the top. With the arraystretch factor set to 1.5, depending on the size of the font, the text is aligned or touches the top.
I would like a solution that always center vertically the text, regardless of the font size and the arraystretch factor.