Skip to content

Instantly share code, notes, and snippets.

@muzimuzhi
Created August 21, 2018 01:04
Show Gist options
  • Save muzimuzhi/5fe13be9c06327f3337010366e83b151 to your computer and use it in GitHub Desktop.
Save muzimuzhi/5fe13be9c06327f3337010366e83b151 to your computer and use it in GitHub Desktop.
latex: how height of tabular row grows
\documentclass{ctexart}
\usepackage{array}
\usepackage{tcolorbox}
\tcbuselibrary{skins, listings}
\tcbset{skin=bicolor, colbacklower=white}
\newtcblisting[auto counter]{example}[1]{
title=例\thetcbcounter: #1
}
\begin{document}
\begin{example}{复现题主的例子}
\linespread{1.0}\selectfont
\begin{tabular}{|c|c|c|c|c|}
\hline
车道宽度(m) & 3.5 & 3.25 & 3 & 2.75 \\ \hline
折减系数 & 1 & 0.94 & 0.85 & 0.77 \\ \hline
\end{tabular}
\end{example}
\begin{example}{使用文档类\texttt{ctexart}的默认效果}
% 相当于 \linespread{1.3}\selectfont
\begin{tabular}{|c|c|c|c|c|}
\hline
车道宽度(m) & 3.5 & 3.25 & 3 & 2.75 \\ \hline
折减系数 & 1 & 0.94 & 0.85 & 0.77 \\ \hline
\end{tabular}
\end{example}
\begin{example}{增加 \texttt{\textbackslash arraystretch}}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|c|c|c|c|c|}
\hline
车道宽度(m) & 3.5 & 3.25 & 3 & 2.75 \\ \hline
折减系数 & 1 & 0.94 & 0.85 & 0.77 \\ \hline
\end{tabular}
\end{example}
\begin{example}{列标\texttt{lrc},纵向靠下对齐}
% \usepackage{array}
\begin{tabular}{>{\small}l|r|>{\huge}c}
\hline
somethine long & somethine long & somethine long \\ \hline
ABC & ABC & ABC \\ \hline
xdy & xdy & xdy \\ \hline
中文abc & 中文abc & 中文abc \\ \hline
中文abc & 中文abc & 中文abc\rule{1pt}{50pt} \\ \hline
\end{tabular}
\end{example}
\begin{example}{列标\texttt{mbp},当行高被同类列撑大时,纵向居中对齐}
% \usepackage{array}
\begin{tabular}{m{2cm}|b{2cm}|p{2cm}|>{abc abc abc abc}m{2cm}}
\hline
ABC & ABC & ABC & \\ \hline
xdy & xdy & xdy & \\ \hline
中文abc & 中文abc & 中文abc & \\ \hline
中文abc & 中文abc & 中文abc & \\ \hline
\end{tabular}
\end{example}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment