라텍스: 중앙 정렬로 빈 행을 얻습니다.

라텍스: 중앙 정렬로 빈 행을 얻습니다.

아래 이미지와 같은 테이블을 갖고 싶습니다.

\documentclass{article}
\begin{document}
    \begin{table*}
        \begin{tabular}{|l|l|l|l|l|l|l|} \hline 
            &\multicolumn{3}{c|}{A} &\multicolumn{3}{c|}{B} \\ \cline{2-7} 
          1 & a & b & c & d & e & f \\ \hline
          2 & g & h & i & j & k & l \\ \hline 
        \end{tabular}
    \end{table*}
\end{document}

그러나 다음과 같이 전체 행이 비어 있는 테이블을 얻을 수 없습니다.콜드 캐시, 중앙에 적혀 있습니다. 그렇게 할 수 있는 방법이 있나요?

여기에 이미지 설명을 입력하세요

또한 표 아래에 캡션을 추가하고 싶습니다.

답변1

다음 코드에서는 원하는 테이블을 재현하는 두 가지 방법을 제공했습니다. 첫 번째 테이블은 요청한 대로 물건을 생산하는 것을 목표로 합니다. 당신은 올바른 길을 가고 있었습니다 \multicolumn. 게시한 이미지에서 대부분의 셀이 오른쪽 정렬된 것처럼 보이기 때문에 저는 r이 아닌 기본 셀 정렬을 만들었습니다 . l왼쪽 정렬된 항목의 경우(\multicolumn{1}{l}{...}, 첫 번째 열에 있는 내용), 이러한 특정 셀의 정렬을 변경하는 명령을 사용했습니다 .

마지막으로, 귀하가 요청한 방식으로 테이블을 생성하지 말 것을 적극 권장합니다. 특히, 나는 다음을 읽어볼 것을 권한다.booktabs선적 서류 비치(특히 섹션 2) 표 조판에 대한 좋은 인쇄 방법에 대한 몇 가지 권장 사항을 참조하세요.

\documentclass{article}

\usepackage{booktabs} % used for prettier tables
\usepackage[justification=centering]{caption} % needed to center caption

\begin{document}

Table~\ref{fig:replication-as-requested} replicates the image as you've requested, but Table~\ref{fig:replication-as-recommended} replicates the image as I would recommend, based on considerations from the \verb|booktabs| documentation.

\begin{table}[htbp]
\centering
\caption{LUBM 1 Billion (time in seconds)}\label{fig:replication-as-requested}
\begin{tabular}{|r|r|r|r|r|r|r|r|}
    \hline
    & Q1 & Q2 & Q3 & Q4 & Q5 & Q6 & Geom.~Mean \\ \hline
    \multicolumn{8}{|c|}{Cold caches} \\ \hline
    \multicolumn{1}{|l|}{RDF-3X} & a & b & c & d & e & f & g  \\ \hline
    \multicolumn{1}{|l|}{MonetDB} & a & b & c & d & e & f & g \\ \hline
    \multicolumn{1}{|l|}{TripleBit} & a & b & c & d & e & f & g \\ \hline
    \multicolumn{8}{|c|}{Warm caches} \\ \hline
    \multicolumn{1}{|l|}{RDF-3X} & a & b & c & d & e & f & g  \\ \hline
    \multicolumn{1}{|l|}{MonetDB} & a & b & c & d & e & f & g \\ \hline
    \multicolumn{1}{|l|}{TripleBit} & a & b & c & d & e & f & g \\ \hline
\end{tabular}
\end{table}

\begin{table}[htbp]
\centering
\caption{LUBM 1 Billion (time in seconds)}\label{fig:replication-as-recommended}
\begin{tabular}{rrrrrrrr}
    \toprule
    & Q1 & Q2 & Q3 & Q4 & Q5 & Q6 & Geom.~Mean \\ \midrule
    \multicolumn{8}{c}{Cold caches} \\ \midrule
    \multicolumn{1}{l}{RDF-3X} & a & b & c & d & e & f & g  \\
    \multicolumn{1}{l}{MonetDB} & a & b & c & d & e & f & g \\
    \multicolumn{1}{l}{TripleBit} & a & b & c & d & e & f & g \\ \midrule
    \multicolumn{8}{c}{Warm caches} \\ \midrule
    \multicolumn{1}{l}{RDF-3X} & a & b & c & d & e & f & g  \\
    \multicolumn{1}{l}{MonetDB} & a & b & c & d & e & f & g \\
    \multicolumn{1}{l}{TripleBit} & a & b & c & d & e & f & g \\ \bottomrule
\end{tabular}
\end{table}

\end{document}

여기에 이미지 설명을 입력하세요

답변2

귀하의 (작동하지 않는 예)를 Johannes_B의 제안 의견을 고려하고 추가하는 MWE로 확장합니다. 테이블 디자인에 관해서는 나도 그 말에 동의한다. 가능한 MWE는 다음과 같습니다.

\documentclass{article}
\begin{document}
    \begin{table}\centering
    \begin{tabular}{*{7}{|l}|} 
        \hline 
  & \multicolumn{3}{c|}{A}
      &\multicolumn{3}{c|}{B}   \\
    \hline
1 & a & b & c & d & e & f       \\
    \hline 
    \multicolumn{7}{|c|}{cold cashes}   \\
    \hline
2 & g & h & i & j & k & l       \\ 
    \hline 
    \end{tabular}
\caption{My very important table}
    \end{table}
\end{document}

위의 예가 도움이 되기를 바랍니다.

답변3

당신이 보여준 이미지에 가까운 또 다른 시도입니다.

여기에 이미지 설명을 입력하세요

\documentclass[]{article}
\usepackage[papersize={18cm,8cm}]{geometry} % change this line in actual case.
\usepackage{multirow}
\begin{document}
    \begin{table}\centering
    \begin{tabular}{*{8}{|c}|} 
        \hline 
 & Q1 & Q2 & Q3 & Q4 & Q5 & Q6 & \multirow{2}{*}{Geom. Mean}\\ \cline{1-7}
 \#Results &10  &10&0&8&2528&4.39997&  \\    \hline
    \multicolumn{8}{|c|}{Cold cashes}   \\    \hline
 RDF-3X &  &&&&&&  \\    \hline
 MonetDB &  &&&&&&  \\    \hline
 TripleBit &  &&&&&&  \\    \hline
    \multicolumn{8}{|c|}{Warm cashes}   \\    \hline
 RDF-3X &  &&&&&&  \\    \hline
 MonetDB &  &&&&&&  \\    \hline
 TripleBit & 0.0002 &0.0002&7.5977&0.0009&27.2772&36.5613& 0.0805 \\    \hline
    \end{tabular}
\caption{LUBMI 1 Billion (time in seconds)}
    \end{table}
\end{document}

관련 정보