問題:如何同時讓表格同一行一個單元格的文字能垂直居中?比如說文字超長超出頁面范圍需要分行顯示
答:(來源於smth)
方案一:
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
%然后使用&\tabincell{c}{}&就可以在表格中自動換行
%比如這么用
\begin{tabular}{|c|c|}
\hline
1 & the first line \\
\hline
2 & \tabincell{c}{haha\\ heihei\\zeze} \\
\hline
\end{tabular}
注:好用,已試過,以下為一例子,可直接存為.tex文件編譯運行
\documentclass[a4paper,12pt]{article}
\usepackage{CJK}
\begin{document}
\begin{CJK*}{GBK}{song}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
%然后使用&\tabincell{c}{}&就可以在表格中自動換行
%比如這么用
\begin{tabular}{|c|c|}
\hline
1 & the first line \\
\hline
2 & \tabincell{c}{haha\\ heihei\\zeze \\fgf \\asgr} \\
\hline
\end{tabular}
\end{CJK*}
\end{document}
方案二:
\usepackage{longtable}
%本人在linux下的,pdfLaTex測試沒有成功,求原因,求解釋。 (lim)
方案三:(要是覺得單元格內容,不分行也行的話)
使用\resizebox{\textwidth}{!}{...}, 用到graphix宏包.
參考資料:Latex, 縮小表格或者橫向表格