我们如何才能使列不居中?例如,半学期 I 位于单元格顶部。我想将其置于单元格的中心下方。
\documentclass[11pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usetheme{Berlin}
\usepackage{graphics}
\usepackage{longtable}
\begin{table}
\begin{center}\label{tab:plan}
\begin{scriptsize}
\begin{longtable}{|p{2.8cm}|p{3.9cm}|p{1.4cm}|p{1.8cm}|}
\hline
\multicolumn{4}{|c|}{\textbf{Timeline and Milestones}}
\\
\hline
\centering \textbf{Specific Objectives} & \centering
\textbf{Tasks} & \centering \textbf{Schedule} &
\textbf{Milestones}
\\
\hline \centering \textbf{1.Literature review and preliminary and background
work} &
\begin{itemize}[topsep=0pt]
\item [a)] Literature review of theory and applications,
\item [b)] Analysing existing the problems,
\item [c)] Familiarizing with the various programs
\end{itemize}&\centering Half Term I & Prepare summary literature survey by end of term
\\
\hline
\end{longtable}
\end{scriptsize}
\end{center}
\end{document}
答案1
你的表格我会这样写:
\documentclass[11pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage{amsmath}
%\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{graphicx}
\usetheme{Berlin}
%\usepackage{graphics} loaded by beamer
%\usepackage{longtable} in presentation hasn't any sense
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\bfseries}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}
\begin{frame}
\begin{table}
%\label{tab:plan}% has sense if table has numered caption
\scriptsize
\centering
\setlength\tabcolsep{3pt}
\setlength{\leftmargini}{4ex}
% \begin{center}
% \begin{scriptsize}
% \begin{longtable}
\begin{tabular*}{\linewidth}{@{}
>{\bfseries}L{\dimexpr0.25\linewidth-2\tabcolsep\relax}
L{\dimexpr0.35\linewidth-2\tabcolsep\relax}
L{\dimexpr0.20\linewidth-2\tabcolsep\relax}
L{\dimexpr0.20\linewidth-2\tabcolsep\relax}
@{}}
\toprule%\hline
\multicolumn{4}{c}{\textbf{Timeline and Milestones}} \\
\midrule%\hline
\thead{Specific\\ Objectives}
& \thead{Tasks}
& \thead{Schedule}
& \thead{Milestones} \\
\midrule%\hline
1. Literature review and preliminary and background work
& \vspace*{-1.2\baselineskip}
\begin{itemize}
\item[a)] Literature review of theory and applications,
\item[b)] Analysing existing the problems,
\item[c)] Familiarizing with the various programs
\vspace*{-\baselineskip}
\end{itemize}
& Half Term I
& Prepare summary literature survey by end of term \\
\midrule%\hline
\end{tabular*}% \end{longtable}
\end{table}
% \end{scriptsize}
% \end{center}
\end{frame}
\end{document}
- 内容
beamer
应该在frame
环境中。 我不会将单元格内容居中,左对齐看起来更好(符合我的口味。但是,如果你坚持将单元格内容居中,那么行
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
替换宽度
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
并使用
C{...}
而不是L{...}
表格列选项。在演示中使用
longtable
没有多大意义(或者我错过了什么?longtable
默认是居中的,所以\begin{center}
...\end{center}
是多余的。longtable
不必在table
环境中。scriptsize
是切换(从使用的字体大小到“脚本”大小)。- 为了使 od 列标题居中,我使用了包
\thead
中的功能makecell
。