我想让表格适合我设置的 paperwidth=16cmx24cm。请问该怎么做?谢谢。以下是代码:
\documentclass[12pt]{book}
\usepackage[paperwidth=16cm, paperheight=24cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,matrix,positioning}
\begin{document}
\begin{center}
\begin{tabular}{|r|r|r|r|r|}
\hline
$Q$ $\ast$& $\Sigma$ $\rightarrow \Gamma$ & & $\ast (R/L)$ & $Q$ \\
\hline
\lipsum \\
\hline
\end{tabular}
\end{center}
\end{document}
根据 Mico 评论进行了编辑
\documentclass[12pt]{book}
\usepackage[paperwidth=16cm, paperheight=24cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{tabularx}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,matrix,positioning}
\begin{document}
\begin{center}
\begin{tabular*}{0.75\textwidth}{|r|r|r|r|r|}
\hline
$Q$ $\ast$& $\Sigma$ $\rightarrow \Gamma$ & & $\ast (R/L)$ & $Q$ \\
\hline
When we stand on a particular state $Q$ & and we have to read a symbole as input & we write someting ont the tape $\Gamma$ & and we move left/on the tape & and we get to the next state. \\
\hline
\end{tabular*}
\begin{tabularx}{0.75\textwidth}{@{\extracolsep{\fill}}|r|r|r|r|r|}
\hline
$Q$ $\ast$& $\Sigma$ $\rightarrow \Gamma$ & & $\ast (R/L)$ & $Q$ \\
\hline
When we stand on a particular state $Q$ & and we have to read a symbole as input & we write someting ont the tape $\Gamma$ & and we move left/on the tape & and we get to the next state. \\
\hline
\end{tabularx}
\end{center}
\end{document}
答案1
我在之前的评论中写道:
如果表格必须具有一定的宽度,请不要使用
tabular
。相反,请使用tabular*
或tabularx
。使用其中哪一个主要取决于内容的表格。
由于附录中的表格需要换行,因此您不应使用tabular*
环境。重点是使tabularx
语法正确。特别是,tabularx
环境的一个或多个列必须类型为X
。(请研究tabularx
环境的用户指南以获取更多信息。)
\documentclass[12pt]{book}
\usepackage[paperwidth=16cm, paperheight=24cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{tabularx,ragged2e}
\newcolumntype{R}{>{\RaggedLeft}X}
\begin{document}
\begin{center}
\begin{tabularx}{0.75\textwidth}{|*{5}{R|}}
\hline
$Q \ast$& $\Sigma \rightarrow \Gamma$ & & $\ast (R/L)$ & $Q$ \\
\hline
When we stand on a particular state~$Q$ & and we have to read a symbole as input & we write someting ont the tape $\Gamma$ & and we move left/on the tape & and we get to the next state. \\
\hline
\end{tabularx}
\end{center}
\end{document}