如何删除除第二条之外的垂直线(如图所示)并使所有文本在垂直和水平方向上居中?谢谢
\documentclass{article}
\usepackage[a4paper,margin=2.5cm]{geometry} % set suitable page parameters
\usepackage[T1]{fontenc}
\usepackage{lmodern,tabularx,ragged2e}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\newcommand\mytab[1]{%
\bgroup%
\setlength\extrarowheight{0pt}%
\smash{\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}%
\egroup}
\usepackage[czech]{babel}
\usepackage{regexpatch}
\makeatletter
\xpatchparametertext\@cline{-}{\cA-}{}{}
\makeatother
\setlength\textwidth{145mm}
\setlength\textheight{247mm}
\setlength\oddsidemargin{15mm}
\setlength\evensidemargin{15mm}
\setlength\topmargin{0mm}
\setlength\headsep{0mm}
\setlength\headheight{0mm}
\let\openright=\clearpage
\begin{document}
\begin{table}[ht!]
\scriptsize
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{2pt} % default: 6pt
\begin{tabularx}{\textwidth}{|*{5}{C|} >{\hsize=1.3\hsize}C| >{\hsize=0.7\hsize}C| *{3}{C|}}
\hline
Veličina & \multicolumn{3}{|c|}{M} & \multicolumn{2}{c|}{C} & R & \multicolumn{3}{c|}{P} \\
\cline{2-10}
\multicolumn{1}{|c|}{} &\multicolumn{3}{|c|}{PHOEBE fotometrie a RV} &
\mytab{POWR\\analýza} &
\mytab{Řešení\\světelných\\křivek a RV} &
CFF & & \\
\cline{2-4}
& Řešení I & Řešení II & Řešení III & & & & Model malá hmotnost & Model střední hmotnost & Model velká hmotnost\\
\hline\hline
& & & & & & & & & \\
& & & & & & & & & \\
\end{tabularx}
\end{table}
\end{document}
答案1
我建议使用两个连续的 tabularx 来解决垂直线问题。至于列标题居中,我建议使用略有不同的布局(“Mod”el 对最后三列是通用的),我用\mytab
包\multirowcell
中的替换makecell
:
\documentclass{article}
\usepackage[a4paper, margin=2.5cm, nohead]{geometry} % set suitable page parameters
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,tabularx,ragged2e, multirow, makecell}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\usepackage[czech]{babel}
\usepackage{regexpatch}
\makeatletter
\xpatchparametertext\@cline{-}{\cA-}{}{}
\makeatother
\let\openright=\clearpage
\begin{document}
\begin{table}[ht!]
\scriptsize
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{2pt} % default: 6pt
\begin{tabularx}{\textwidth}{|*{5}{C|}>{\hsize=1.3\hsize}C| >{\hsize=0.7\hsize}C| *{3}{C|}}
\hline
\multirowcell{4}{Veličina} & \multicolumn{3}{c|}{M} & \multicolumn{2}{c|}{C} & R & \multicolumn{3}{c|}{P} \\
\cline{2-10}
\multicolumn{1}{|c|}{} &\multicolumn{3}{c|}{PHOEBE fotometrie a RV} &
\multirowcell{3}{POWR\\analýza} &
\multirowcell{3}{Řešení\\světelných\\křivek a RV} &
\multirowcell{2}{CFF }& \multicolumn{3}{c|}{ Model } \\
\cline{2-4}\cline{8-10}
& Řešení I & Řešení II & Řešení III & & & & malá hmotnost & střední hmotnost & velká hmotnost \\
\hline
\end{tabularx}\vskip 0.3ex
\begin{tabularx}{\textwidth}{C|*{5}{C} >{\hsize=1.3\hsize}C >{\hsize=0.7\hsize}C *{3}{C}}
\hline
& & & & & & & & & \\
& & & & & & & & & \\
& & & & & & & & & \\
& & & & & & & & & \\
\end{tabularx}
\end{table}
\end{document}
其他可能性:
\begin{table}[ht!]
\scriptsize%
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{2pt} % default: 6pt
\begin{tabularx}{\textwidth}{|*{5}{C|}>{\hsize=1.6\hsize}C| >{\hsize=0.4\hsize}C| *{3}{C|}}
\hline
\multirowcell{4}{Veličina} & \multicolumn{3}{c|}{M} & \multicolumn{2}{c|}{C} & R & \multicolumn{3}{c|}{P} \\
\cline{2-10}
\multicolumn{1}{|c|}{} &\multicolumn{3}{c|}{\multirowcell{1.5}{PHOEBE fotometrie a RV}}
& \multirow{3}{=}{\centering POWR analýza} & %
\multirow{3}{=}{\centering Řešení světelných křivek a RV} &
\multirowcell{3}{CFF }& \multirow{3}{=}{\centering Model malá hmotnost} & \multirow{3}{=}{\centering Model střední hmotnost} & \multirow{3}{=}{\centering Model velká hmotnost} \\[1ex]
\cline{2-4}
& \multirowcell{1.5}{Řešení I} & \multirowcell{1.5}{Řešení II} &\multirowcell{1.5}{Rešení III} & & & & & &\\ [1.5ex]
\hline
\end{tabularx}\vskip 0.3ex
\begin{tabularx}{\textwidth}{C|*{4}{C} >{\hsize=1.3\hsize}C >{\hsize=0.7\hsize}C *{3}{C}}
\hline
& & & & & & & & & \\
& & & & & & & & & \\
& & & & & & & & & \\
& & & & & & & & & \\
\end{tabularx}
\end{table}