LaTeX로 테이블을 만들고 싶어서 다음 프로그램을 작성했습니다.
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{color}
\begin{document}
\begin {center}
\begin {tabular}{| l | l | l | l | l | l |}
\cline{2-6}
& \multicolumn{5}{ |c| }{$\eta_{\infty}$} \\ \cline{2-6}
& i=1,f=6 & i=1,f=3 & i=3,f=5& i=4,f=2& i=6,f=3 \\ \hline
$k,l=0,0$ & \textcolor{blue}{0.1811} & \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811} \\ \hline
$k,l=1,2$ &0.3788 &0.3788 &0.2898 &0.2220 &0.2898 \\ \hline
$k,l=1,3$ &0.3788 &\textcolor{red}{0.9393} &0.2898 &0.2898 &0.2220 \\ \hline
$k,l=1,4$ &0.3788 &0.3788 &0.2898 &0.3788 &0.2898 \\ \hline
$k,l=1,5$ &0.3788 &0.3788 &0.2220 &0.2898 &0.2898 \\ \hline
$k,l=1,6$ &\textcolor{red}{0.9393} &0.3788 &0.2898 &0.2898 &0.3788 \\ \hline
$k,l=2,3$ &0.2898 &0.2220 &0.3788 &0.2220 &0.2220 \\ \hline
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\textcolor{red}{0.9393} &0.2898 \\ \hline
$k,l=2,5$ &0.2898 &0.2898 &0.2220 &0.2220 &0.2898 \\ \hline
$k,l=2,6$ &0.2220 &0.2898 &0.2898 &0.2220 &0.3788\\ \hline
$k,l=3,4$ &0.2898 &0.2220 &0.3788 &0.3788 &0.2220 \\ \hline
$k,l=3,5$ &0.2898 &0.2220 &\textcolor{red}{0.9393} &0.2898 &0.2220 \\ \hline
$k,l=3,6$ &0.2220 &0.2220 &0.3788 &0.2898 &\textcolor{red}{0.9393} \\ \hline
$k,l=4,5$ &0.2898 &0.2898 &0.2220 &0.3788 &0.2898 \\ \hline
$k,l=4,6$ &0.2220 &0.2898 &0.2898 &0.3788 &0.3788 \\ \hline
$k,l=5,6$ &0.2220 &0.2898 &0.2220 &0.2898 &0.3788 \\ \hline
\end {tabular}\\
Table 2: System efficiency for different k,l and i,f.
\end {center}
\end{document}
일부 셀의 첫 번째 열에 추가 수직선이 있는데 어떻게 생략할 수 있나요? 곧 답변해 주셔서 감사합니다!
답변1
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{color}
\begin{document}
\begin {table}\centering
\begin {tabular}{| l | l | l | l | l | l |}
\cline{2-6}
\multicolumn{1}{c|}{}&\multicolumn{5}{c| }{$\eta_{\infty}$} \\ \cline{2-6}
\multicolumn{1}{c|}{}& i=1,f=6 & i=1,f=3 & i=3,f=5& i=4,f=2& i=6,f=3 \\ \hline
$k,l=0,0$ & \textcolor{blue}{0.1811} & \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811} \\ \hline
$k,l=1,2$ &0.3788 &0.3788 &0.2898 &0.2220 &0.2898 \\ \hline
$k,l=1,3$ &0.3788 &\textcolor{red}{0.9393} &0.2898 &0.2898 &0.2220 \\ \hline
$k,l=1,4$ &0.3788 &0.3788 &0.2898 &0.3788 &0.2898 \\ \hline
$k,l=1,5$ &0.3788 &0.3788 &0.2220 &0.2898 &0.2898 \\ \hline
$k,l=1,6$ &\textcolor{red}{0.9393} &0.3788 &0.2898 &0.2898 &0.3788 \\ \hline
$k,l=2,3$ &0.2898 &0.2220 &0.3788 &0.2220 &0.2220 \\ \hline
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\textcolor{red}{0.9393} &0.2898 \\ \hline
$k,l=2,5$ &0.2898 &0.2898 &0.2220 &0.2220 &0.2898 \\ \hline
$k,l=2,6$ &0.2220 &0.2898 &0.2898 &0.2220 &0.3788\\ \hline
$k,l=3,4$ &0.2898 &0.2220 &0.3788 &0.3788 &0.2220 \\ \hline
$k,l=3,5$ &0.2898 &0.2220 &\textcolor{red}{0.9393} &0.2898 &0.2220 \\ \hline
$k,l=3,6$ &0.2220 &0.2220 &0.3788 &0.2898 &\textcolor{red}{0.9393} \\ \hline
$k,l=4,5$ &0.2898 &0.2898 &0.2220 &0.3788 &0.2898 \\ \hline
$k,l=4,6$ &0.2220 &0.2898 &0.2898 &0.3788 &0.3788 \\ \hline
$k,l=5,6$ &0.2220 &0.2898 &0.2220 &0.2898 &0.3788 \\ \hline
\end {tabular}
\caption{System efficiency for different $k,l$ and $i,f$.}
\end {table}
\end{document}
답변2
David Carlisle의 솔루션 외에도 모든 수직선을 억제하고 및 패키지를 사용하고 booktabs
싶습니다 cellspace
. 이 패키지는 접두사가 붙은 지정자를 사용하여 열의 셀 상단과 하단에 최소 수직 간격을 보장합니다 S
. 또한 table environment, and a
이 테이블에 대한 상호 참조를 가질 수 있도록 \caption` 명령을 사용했습니다 .
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{array}
\usepackage{color}
\usepackage{cellspace, booktabs}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\begin{document}
\begin{table}
\centering
\begin {tabular}{Sl*{5}{Sc}}
& \multicolumn{5}{Sc }{$\eta_{\infty}$} \\
\cmidrule[\heavyrulewidth]{2-6}
& i=1,f=6 & i=1,f=3 & i=3,f=5& i=4,f=2& i=6,f=3 \\
\midrule
$k,l=0,0$ & \textcolor{blue}{0.1811} & \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811} \\
$k,l=1,2$ &0.3788 &0.3788 &0.2898 &0.2220 &0.2898 \\
$k,l=1,3$ &0.3788 &\textcolor{red}{0.9393} &0.2898 &0.2898 &0.2220 \\
$k,l=1,4$ &0.3788 &0.3788 &0.2898 &0.3788 &0.2898 \\
$k,l=1,5$ &0.3788 &0.3788 &0.2220 &0.2898 &0.2898 \\
$k,l=1,6$ &\textcolor{red}{0.9393} &0.3788 &0.2898 &0.2898 &0.3788 \\
$k,l=2,3$ &0.2898 &0.2220 &0.3788 &0.2220 &0.2220 \\
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\textcolor{red}{0.9393} &0.2898 \\
$k,l=2,5$ &0.2898 &0.2898 &0.2220 &0.2220 &0.2898 \\
$k,l=2,6$ &0.2220 &0.2898 &0.2898 &0.2220 &0.3788\\
$k,l=3,4$ &0.2898 &0.2220 &0.3788 &0.3788 &0.2220 \\
$k,l=3,5$ &0.2898 &0.2220 &\textcolor{red}{0.9393} &0.2898 &0.2220 \\
$k,l=3,6$ &0.2220 &0.2220 &0.3788 &0.2898 &\textcolor{red}{0.9393} \\
$k,l=4,5$ &0.2898 &0.2898 &0.2220 &0.3788 &0.2898 \\
$k,l=4,6$ &0.2220 &0.2898 &0.2898 &0.3788 &0.3788 \\
$k,l=5,6$ &0.2220 &0.2898 &0.2220 &0.2898 &0.3788 \\
\bottomrule
\end {tabular}
\caption{System efficiency for different $ k,l $ and i,f.}\label{effi}
\end {table}
답변3
두 번째 헤더 행의 자료를 첫 번째 열의 형태에 맞게 재구성하는 솔루션은 다음과 같습니다. 또한 S
(패키지의 siunitx
) 열 유형을 사용하여 소수점 표시에서 열 2부터 6까지의 숫자 데이터 요소를 정렬합니다. (이 설정의 효과를 강조하기 위해 소수점 뒤에 두 자리 또는 세 자리가 있도록 일부 숫자를 변경했습니다.) 또한 모든 수직선과 대부분의 수평선을 제거할 것을 제안합니다. 저를 믿으십시오. 놓치지 않을 것입니다.
\documentclass{article}
\usepackage{color,siunitx,booktabs}
\begin{document}
\begin{table}
\begin{tabular*}{\textwidth}{ @{} @{\extracolsep{\fill}} l *{5}{S[table-format=1.4]} @{} }
\toprule
& \multicolumn{5}{ c@{} }{$\eta_{\infty}$} \\
\cmidrule(l){2-6}
& {$i,f=1,6$}& {$i,f=1,3$}& {$i,f=3,5$}& {$i,f=4,2$}& {$i,f=6,3$} \\
\midrule
$k,l=0,0$ & \color{blue}0.1811& \color{blue}0.1811& \color{blue}0.1811& \color{blue}0.1811& \color{blue}0.1811 \\
$k,l=1,2$ &0.38 &0.38 &0.2898 &0.222 &0.2898 \\
$k,l=1,3$ &0.38 &\color{red}0.9393&0.2898 &0.2898 &0.222 \\
$k,l=1,4$ &0.38 &0.38 &0.2898 &0.38 &0.2898 \\
$k,l=1,5$ &0.38 &0.38 &0.222 &0.2898 &0.2898 \\
$k,l=1,6$ &\color{red}0.9393&0.38 &0.2898 &0.2898 &0.38 \\
$k,l=2,3$ &0.2898 &0.222 &0.38 &0.222 &0.222 \\
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\color{red}0.9393&0.2898 \\
$k,l=2,5$ &0.2898 &0.2898 &0.222 &0.222 &0.2898 \\
$k,l=2,6$ &0.222 &0.2898 &0.2898 &0.222 &0.38\\
$k,l=3,4$ &0.2898 &0.222 &0.38 &0.38 &0.222 \\
$k,l=3,5$ &0.2898 &0.222 &\color{red}0.9393&0.2898 &0.222 \\
$k,l=3,6$ &0.222 &0.222 &0.38 &0.2898 &\color{red}0.9393 \\
$k,l=4,5$ &0.2898 &0.2898 &0.222 &0.38 &0.2898 \\
$k,l=4,6$ &0.222 &0.2898 &0.2898 &0.38 &0.38 \\
$k,l=5,6$ &0.222 &0.2898 &0.222 &0.2898 &0.38 \\
\bottomrule
\end{tabular*}
\caption{System efficiency for various combinations of $k,l$ and $i,f$.}
\end{table}
\end{document}