包装单元格内容

包装单元格内容

我的朋友们,在下表中,在指定列名的第一行中,我想将“名义”和“批发”移动到下一行(但当然在同一个单元格中)。

在此处输入图片描述

我也想将这两列的内容居中。请提出建议

\documentclass{article}
%\usepackage{showframe}% http://ctan.org/pkg/showframe
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{calc}
\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet2'
\begin{table}[htbp]
  \noindent\hspace*{-1cm}\begin{tabularx}{\textwidth+2cm}{
>{\raggedleft\arraybackslash\advance\hsize1em}X
>{\raggedright\arraybackslash\advance\hsize1em }X
>{\raggedright\arraybackslash}X
>{\raggedright\arraybackslash\advance\hsize-1em }X
>{\raggedright\arraybackslash\advance\hsize-1em }X
}

\addlinespace
\toprule
\multicolumn{1}{c}{Country} & Price series selected & Retail/Wholesale & Real/Nominal &     Location \\
\midrule
Afghanistan & Bread & R     & R     & Kabul \\
\bottomrule
\end{tabularx}\hspace*{-1cm}%
\label{Selected food price series}%
\end{table}%
\end{document} 

答案1

\multicolumn{1}{c}{Country} & Price series selected &
   \centering Retail/\\Wholesale & 
  \centering Real/\\Nominal &     Location \\

在此处输入图片描述

或完整内容:

\documentclass{article}
%\usepackage{showframe}% http://ctan.org/pkg/showframe
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{calc}
\begin{document}

% Table generated by Excel2LaTeX from sheet 'Sheet2'
\begin{table}[htbp]
  \noindent\hspace*{-1cm}\begin{tabularx}{\textwidth+2cm}{
>{\raggedleft\advance\hsize1em}X
>{\raggedright\advance\hsize1em }X
>{\centering}X
>{\centering\advance\hsize-1em }X
>{\raggedright\arraybackslash\advance\hsize-1em }X
}

\addlinespace
\toprule
\centering Country & Price series selected & Retail/\\Wholesale &  Real/\\Nominal &     Location \\
\midrule
Afghanistan & Bread & R     & R     & Kabul \\
\bottomrule
\end{tabularx}\hspace*{-1cm}%
\label{Selected food price series}%
\end{table}%
\end{document} 

相关内容