![如何让表格填满整个水平空间?](https://linux22.com/image/283791/%E5%A6%82%E4%BD%95%E8%AE%A9%E8%A1%A8%E6%A0%BC%E5%A1%AB%E6%BB%A1%E6%95%B4%E4%B8%AA%E6%B0%B4%E5%B9%B3%E7%A9%BA%E9%97%B4%EF%BC%9F.png)
我希望表格适合可用的水平空间。如何解决这个问题?
\documentclass[12pt]{article}
\usepackage[a4paper,hmargin=1cm,landscape,includemp,showframe]{geometry}
\usepackage{array}
\usepackage{xcolor}
\usepackage{helvet}
\pagestyle{empty}
\begin{document}
\begin{center}
\Huge\bfseries Mathematics and Physics Schedule
\end{center}
\noindent
\begin{tabular}{|>{\centering\arraybackslash}m{25mm}|*5{>{\centering\arraybackslash}m{\dimexpr\dimexpr\textwidth-25mm\relax/5\relax}|}}\hline
Time & Monday & Tuesday & Wednesday & Thursday & Friday \\\hline
16:00-16:30 &&&&&\\\hline
16:30-17:00 &&&&&\\\hline
17:00-17:30 &&&&&\\\hline
17:30-18:00 &&&&&\\\hline
18:00-18:30 &&&&&\\\hline
18:30-19:00 &&&&&\\\hline
\end{tabular}
\end{document}
答案1
\resizebox
始终是一个选项:
\documentclass[12pt]{article}
\usepackage[a4paper,hmargin=1cm,landscape,includemp,showframe]{geometry}
\usepackage{array}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{helvet}
\pagestyle{empty}
\begin{document}
\begin{center}
\Huge\bfseries Mathematics and Physics Schedule
\end{center}
\noindent%
\resizebox{\textwidth}{!}{%
\begin{tabular}{|>{\centering\arraybackslash}m{25mm}|*5{>{\centering\arraybackslash}m{\dimexpr\dimexpr\textwidth-25mm\relax/5\relax}|}}\hline
Time & Monday & Tuesday & Wednesday & Thursday & Friday \\\hline
16:00-16:30 &&&&&\\\hline
16:30-17:00 &&&&&\\\hline
17:00-17:30 &&&&&\\\hline
17:30-18:00 &&&&&\\\hline
18:00-18:30 &&&&&\\\hline
18:30-19:00 &&&&&\\\hline
\end{tabular}%
}
\end{document}
答案2
使用以下内容设置includemp=false
并定义表格。
|>{\centering\arraybackslash}m{25mm}|*5{>{\centering\arraybackslash}m{\dimexpr\dimexpr\textwidth-25mm-12\tabcolsep-7\arrayrulewidth\relax/5\relax}|}
答案3
\documentclass[12pt]{article}
\usepackage[a4paper,hmargin=1cm,landscape,showframe]{geometry}
\usepackage{tabularx,ragged2e}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{|m{25mm}|*5{X|}}\hline
Time & Monday & Tuesday & Wednesday & Thursday & Friday \\\hline
16:00-16:30 &&&&&\\\hline
16:30-17:00 &&&&&\\\hline
17:00-17:30 &&&&&\\\hline
17:30-18:00 &&&&&\\\hline
18:00-18:30 &&&&&\\\hline
18:30-19:00 &&&&&\\\hline
\end{tabularx}
\end{document}