我需要在表格的单元格中添加一些左边的空格。有谁可以帮我?
它遵循一个代码示例;我需要在标签不是粗体的第一列的单元格中添加左间距。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{graphics}
\begin{document}
{
\begin{table}[ht]
\centering
\setlength{\tabcolsep}{2pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering\arraybackslash}p{0.15\textwidth}|}
\hline
& \textbf{VRE} & \textbf{FPE} & \textbf{MPE} & \multicolumn{2}{c|}{\textbf{Full sample}} \\
& \textit{n} & \textit{n} & \textit{n} & \textit{n} & \textit{\%} \\
\hline
\textbf{Gender} &&&&& \\
Female & 12 & 10 & 18 & 40 & 52.6 \\
Male & 10 & 13 & 13 & 36 & 47.4 \\
\hline
\textbf{Educational level} &&&&& \\
High School & 8 & 5 & 6 & 19 & 25.0 \\
Bachelor's Degree & 13 & 9 & 19 & 41 & 53.9 \\
Master's Degree & 1 & 8 & 6 & 15 & 19.7 \\
PhD & 0 & 1 & 0 & 1 & 1.3 \\
\hline \hline
\textbf{Age} &&&&& \\
Mean & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
Median & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
\hline
\end{tabular}
\caption{Participants demographic information}
\label{tab:demographic}
\end{table}
}
提前谢谢。
发布于 2021-12-02 14:42:58
一种可能性是:您可以在这些单元格的开头放置\quad
(或类似的空格宏):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{graphics}
\begin{document}
{
\begin{table}[ht]
\centering
\setlength{\tabcolsep}{2pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|p{0.26\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering\arraybackslash}p{0.15\textwidth}|}
\hline
& \textbf{VRE} & \textbf{FPE} & \textbf{MPE} & \multicolumn{2}{c|}{\textbf{Full sample}} \\
& \textit{n} & \textit{n} & \textit{n} & \textit{n} & \textit{\%} \\
\hline
\textbf{Gender} &&&&& \\
\quad Female & 12 & 10 & 18 & 40 & 52.6 \\
\quad Male & 10 & 13 & 13 & 36 & 47.4 \\
\hline
\textbf{Educational level} &&&&& \\
\quad High School & 8 & 5 & 6 & 19 & 25.0 \\
\quad Bachelor's Degree & 13 & 9 & 19 & 41 & 53.9 \\
\quad Master's Degree & 1 & 8 & 6 & 15 & 19.7 \\
\quad PhD & 0 & 1 & 0 & 1 & 1.3 \\
\hline \hline
\textbf{Age} &&&&& \\
\quad Mean & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
\quad Median & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
\hline
\end{tabular}
\caption{Participants demographic information}
\label{tab:demographic}
\end{table}
}
\end{document}
这与问题无关,但是固定宽度的列“浪费”了大量空间。我会使用如下所示的tabularx
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{graphics}
\begin{document}
{
\begin{table}[ht]
\centering
\setlength{\tabcolsep}{10pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\textwidth}{ | X ccccc | }
\hline
& \textbf{VRE} & \textbf{FPE} & \textbf{MPE} & \multicolumn{2}{c|}{\textbf{Full sample}} \\
& \textit{n} & \textit{n} & \textit{n} & \textit{n} & \textit{\%} \\
\hline
\textbf{Gender} &&&&& \\
\quad Female & 12 & 10 & 18 & 40 & 52.6 \\
\quad Male & 10 & 13 & 13 & 36 & 47.4 \\
\hline
\textbf{Educational level} &&&&& \\
\quad High School & 8 & 5 & 6 & 19 & 25.0 \\
\quad Bachelor's Degree & 13 & 9 & 19 & 41 & 53.9 \\
\quad Master's Degree & 1 & 8 & 6 & 15 & 19.7 \\
\quad PhD & 0 & 1 & 0 & 1 & 1.3 \\
\hline \hline
\textbf{Age} &&&&& \\
\quad Mean & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
\quad Median & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
\hline
\end{tabularx}
\caption{Participants demographic information}
\label{tab:demographic}
\end{table}
}
\end{document}
https://stackoverflow.com/questions/70200924
复制相似问题