.png)
\documentclass{article}
\usepackage{}
\usepackage{makecell, multirow, tabularx}
\begin{document}
\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
\begin{tabularx}{\textwidth}{X |c |c |c |c |}
\cline{2-5}
& Mean & N & Std. Deviation & Std. Error Mean \\
\hline
Testing123 Testin123 Testing123 Testin123 & 23\% & 10\% & 279\% & 233\% \\
\hline
\end{tabularx}
\caption{Testing123 Testin123Testing123 Testin123}
\end{table}
여러 열로 추가했습니다
\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
\begin{tabularx}{\textwidth}{X |c |c |c |c |}
\cline{2-5}
& Mean & N & Std. Deviation & Std. Error Mean \\
\hline
\multicolumn{1}{|c|}{Testing123 Testin123 Testing123 Testin123} & 23\% & 10\% & 279\% & 233\% \\
\hline
\end{tabularx}
\caption{Testing123 Testin123Testing123 Testin123}
\end{table}
결과:
그리고 "Testing123 Testin123 Testing123 Testin123"을 2줄로 만들고 싶었습니다.
답변1
@Jennifer의 코드를 보면 첫 번째 헤더 셀(Mean)의 왼쪽 세로선이 다음 행의 세로선과 정렬되지 않는 것을 볼 수 있습니다. 이는 수직바( |
)가 올바르게 배치되지 않았기 때문입니다. 첫 번째 열의 |
오른쪽 에 을 설정해야 합니다 .X
\multicolumn
제거하다\multicolumn
두 번째 헤더 셀의 명령입니다 . 첫 번째 행은 다음과 같습니다.
\multicolumn{1}{X|}{} & Mean & N & Std. Deviation & Std. Error Mean \\
완전한 MWE는 다음과 같습니다.
\documentclass{article}
\usepackage{tabularx, caption} % Load package caption for better captions
\usepackage{booktabs, ragged2e} % Use ragged2e to improve ragged text
\setlength\extrarowheight{1pt} % Both line necessary for decent spacing
\renewcommand{\arraystretch}{1.2}
\begin{document}
\begin{table}[!ht]
\caption{Testing123 Testin123Testing123 Testin123% % Caption above table
\label{tab:test123}% % Label inside caption
}
\begin{tabularx}{\textwidth}{|>{\RaggedRight\arraybackslash}X|c |c |c |c |}
\cline{2-5}
\multicolumn{1}{X|}{} % Right vertical rules in first header cell
& Mean % Remove `multicolumn` from second header cell
& N & Std. Deviation
& Std. Error Mean \\
\hline
Testing123 Testin123 Testing123 Testin123 & 23\% & 10\% & 279\% & 233\% \\
\hline
\end{tabularx}
\end{table}
그러나 표 형식을 다른 방식으로 조판하는 것이 좋습니다.
- 사용책꽂이더 나은 규칙을 위해
- 모든 수직적 규칙을 제거하십시오(북탭 매뉴얼)
@{}
왼쪽 및 오른쪽 베어링을 제거하는 데 사용합니다 .- 새로운 열 유형을 정의하여 너비가 동일한 그림으로 4개의 열을 설정합니다.
- 그림 열을 오른쪽 정렬로 설정
- 백분율 기호를 헤더로 이동
표 형식의 전문은 다음과 같습니다.
\begin{tabularx}{\textwidth}{@{}M*{4}{N}@{}}
이는 다음을 의미합니다.
@{}
= 첫 번째 열의 왼쪽에 있는 측면 베어링, 즉 첫 번째 열의 시작 부분에 보이는 작은 공간을 제거합니다.M
= 유형의 열 하나를 설정합니다 ( 문서 서문의M
명령을 사용하여 정의했습니다 ).\newcolumntype
*{4}{N}
=는 4개의 유형 열 ( 문서 서문의N
명령을 사용하여 정의함 )을 생성한다는 의미입니다. 이번 MWE에서\newcolumntype
4개를 쓰는 것과 같지만NNNN
평소에는 단축키이다.@{}
= 마지막 열에 대해 위의 항목 1과 동일: 측면 베어링을 제거합니다.오른쪽다섯 번째 열의즉마지막 열 끝에 보이는 작은 공간입니다.
이제 더 이해하기 쉬워졌기를 바랍니다.
\documentclass{article}
\usepackage{tabularx, caption} % Load package caption for decent foramtting and spacing
\usepackage{booktabs, ragged2e} % Use booktabs rules and get rid of vertical rules,
% ragged2e to improved ragged right and left text
\setlength\extrarowheight{1pt} % Both line necessary for decent spacing, unless you are using booktabs rules.
\renewcommand{\arraystretch}{1.2}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash\hsize=2\hsize\linewidth=\hsize}X}
\newcolumntype{W}{>{\RaggedLeft\arraybackslash\hsize=0.75\hsize\linewidth=\hsize}X}
\begin{document}
\begin{table}[!ht]
\caption{Testing123 Testin123Testing123 Testin123%
\label{tab:test123}%
}
\begin{tabularx}{\textwidth}{@{}Y*{4}{W}@{}}
\toprule
& \small Mean (\%)
& \small N (\%)& \small Std. Deviation~(\%)
& \small Std. Error Mean (\%)\\
\midrule
Testing123 Testin123 Testing123 Testin123 & 23 & 10 & 279 & 233 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
답변2
머리글 행에 여러 열을 두 번 첨부했습니다. 이것이 당신이 찾고 있는 것이기를 바랍니다.
\documentclass{article}
\usepackage{}
\usepackage{makecell, multirow, tabularx}
\begin{document}
\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
\begin{tabularx}{\textwidth}{|X|c |c |c |c |}
\cline{2-5}
\multicolumn{1}{l}{}
& \multicolumn{1}{|l|}{Mean} & N & Std. Deviation & Std. Error Mean \\
\hline
Testing123 Testin123 Testing123 Testin123 & 23\% & 10\% & 279\% & 233\% \\
\hline
\end{tabularx}
\caption{Testing123 Testin123Testing123 Testin123}
\end{table}
\end{document}