Tabulary = 垂直对齐不佳?

Tabulary = 垂直对齐不佳?

我正在尝试制作一个表格,并使用 tabulary 包来获得合适的列宽。但这里第二列和第三列的值是顶部对齐的,而我希望它们垂直居中。我该怎么做?

我当前的代码是:

\PassOptionsToPackage{setpagesize=false}{hyperref} 
\documentclass[a4paper,11pt,twoside]{article}
\usepackage{amsmath,amssymb}
\usepackage[frenchb]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsfonts}
\usepackage[left=1.5in,right=1.3in,top=1.1in,bottom=1.1in,includefoot,includehead,headheight=26pt]{geometry}
\renewcommand{\baselinestretch}{1.05}
\usepackage{tabulary}

\begin{document}

\begin{table}
\noindent
\begin{tabulary}{\textwidth}{ | L | C | C | }
\hline
\centering A long title that is wrapped on several lines & A long title that is wrapped on several lines & A long title that is wrapped on several lines \\
\hline 
A random text & 2 & 0.025 \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.25$ & 2 & ? \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.5$ & 2 & 1 \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.75$ & 2 & A \\
\hline
A very very very very very very very very very very very very very long random text : $\varepsilon=0.75$ & 2 & A \\
\hline
\end{tabulary}
\caption{A random caption.}
\end{table}
\end{document}

谢谢 !

编辑:完整代码

答案1

在此处输入图片描述

\PassOptionsToPackage{setpagesize=false}{hyperref} 
\documentclass[a4paper,11pt,twoside]{article}
\usepackage{amsmath,amssymb}
\usepackage[frenchb]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsfonts}
\usepackage[left=1.5in,right=1.3in,top=1.1in,bottom=1.1in,includefoot,includehead,headheight=26pt]{geometry}
\renewcommand{\baselinestretch}{1.05}
\usepackage{tabulary}

\setlength\extrarowheight{4pt}

\def\zz{\ifx\[$\else\aftergroup\zzz\fi}
\def\zzz{\setbox0\lastbox
\dimen0\dimexpr\extrarowheight + \ht0-\dp0\relax
\setbox0\hbox{\raise-.5\dimen0\box0}%
\ht0=\dimexpr\ht0+\extrarowheight\relax
\dp0=\dimexpr\dp0+\extrarowheight\relax 
\box0
}


\begin{document}

\begin{table}
\noindent
\begin{tabulary}{\textwidth}{ | >{\zz}L | >{\zz}C | >{\zz}C | }
\hline
\centering A long title that is wrapped on several lines & A long title that is wrapped on several lines & A long title that is wrapped on several lines \\
\hline 
A random text & 2 & 0.025 \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.25$ & 2 & ? \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.5$ & 2 & 1 \\
\hline
A quite long random text (wrapped on 2 lines) : $\varepsilon=0.75$ & 2 & A \\
\hline
A very very very very very very very very very very very very very long random text : $\varepsilon=0.75$ & 2 & A \\
\hline
\end{tabulary}
\caption{A random caption.}
\end{table}
\end{document}


\documentclass{article}

\usepackage{tabulary}
\setlength\extrarowheight{4pt}

\def\zz{\ifx\[$\else\aftergroup\zzz\fi}
\def\zzz{\setbox0\lastbox
\dimen0\dimexpr\extrarowheight + \ht0-\dp0\relax
\raise-.5\dimen0\box0 
}

\begin{document}

\noindent
\begin{tabulary}{\textwidth}{ | L | >{\zz}C | >{\zz}C | }
\hline
\centering Long column title .......... & Long column title .......... & Long column title .......... \\
\hline 
A random text & 2 & 0.025 \\
\hline
A random quite long text : $\varepsilon=0.25$ & 2 & ABC \\
\hline
A random quite long text : $\varepsilon=0.5$ & 2 & 123 \\
\hline
A random quite long text : $\varepsilon=0.75$ & 2 & A1B \\
\hline
\end{tabulary}

\end{document}

相关内容