2

I tried to use column type m, but not working.

enter image description here

Can someone help me ?

MWE for test

\documentclass{article}
\usepackage{array}
\usepackage{caption}
\captionsetup[table]{singlelinecheck=off, font=small,labelfont=bf,skip=0pt}

\begin{document}

\begin{table}[h]    
    \caption{Test Table}
    \begin{tabular}{|m{4em}|m{8em}|}    
        \hline
        Test & Test \\ 
        \hline
        Test & Test\\
        \hline
    \end{tabular}

\end{table}

\end{document}
  • 1
    What doesn't work? What is the expected output? – Ulrike Fischer Oct 20 '17 at 15:54
  • 1
    Your test words have no descenders, only ascenders. That's why the output may look like it's not centered vertically. If you replace all instances of "Test" with "Testing", you'll discover that vertical alignment is indeed being performed. If you merely want more vertical separation between the cell contents and the horizontal lines above them, execute the following instruction: \setlength\extrarowheight{1pt}. – Mico Oct 20 '17 at 15:58
  • yes, you are right, just because there is no descenders @Mico – sun0727 Oct 20 '17 at 16:22
2

Since all cells in your example contain just one row of text, the output produced by using the m column type is the same as would be generated if, say, the l column type were used.

The 'test word' in your example -- "Test" -- happens to contain two letters with ascenders but no words with descenders. This (presumably non-reprentative) test word falsely creates the impression that no centering is being performed. However, as the example words in the first column of the following screenshot show, words with neither ascenders nor descenders (such as "ease" and "cream") are, in fact,easily seen to be centered. It's only if the cells contain words without ascenders (col. 2) or without descenders (col. 3) that one might get the impression that vertical centering isn't being performed.

enter image description here

If you wanted to deliberately override the centering behavior and, instead, create a bit more whitespace between words and the line right above them, you could do so by loading the array package and issuing an instruction such as \setlength\extrarowheight{2pt}.

enter image description here

\documentclass{article}
\usepackage{array}
\begin{document}

\begin{tabular}{|*{4}{c|}}    
\hline
ease cream & gag & hole blow & fishy glue \\
\hline
\end{tabular}

\medskip
\setlength\extrarowheight{2pt}
\begin{tabular}{|*{4}{c|}}    
\hline
ease cream & gag & hole blow & fishy glue \\
\hline
\end{tabular}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.