如何才能阻止我的 latex 表格不必要地从下一页开始,从而在上一页留下大量空白?如何才能强制从标题后开始。请帮忙,这是我的代码:我正在使用包:
\usepackage{tabularx,ragged2e,booktabs,caption},
\usepackage{float}
我的表格的代码是:
\documentclass[11pt]{report}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{natbib}
% Load up special logo commands.
\usepackage{doc}
\usepackage[english]{babel}
\addto{\captionsenglish}{%
\renewcommand{\bibname}{References}
}
% Package for formatting URLs.
\usepackage{url}
\usepackage{amsmath}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{tabularx,ragged2e,booktabs,caption}
\usepackage{graphicx}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
\usepackage{titlesec}
\usepackage{float}
\begin{document}
\chapter{Introduction}
\section{Syntax summary}
\textbf{Basic regular expression syntax}
\vspace{1.5mm}
\hrule
\begin{table}[H]
\begin{tabular}{| l| l }
$.$ & Matches any character.\\
$*$ & Matches zero or more instances of the previous pattern item.\\
$+$ & Matches one or more instances of the previous pattern item.\\
$?$ & Matches zero or one instances of the previous pattern item.\\
$( )$ & Groups a subpattern. The repetition and alternation operators apply to the preceding subpattern.\\
$|$ & Alternation.\\
$[ ]$ & Delimit a set of characters. Ranges are specified as [x-y].\\
\textasciicircum & Anchor the pattern to the beginning of the string. Only when first.\\
\$ & Anchor the pattern to the end of the string. Only when last.\\
\end{tabular}
\end{table}
\hrule
\vspace{1.5mm}
\textbf{Advanced regular expression syntax.}
\vspace{1.5mm}
\hrule
\begin{table}[H]
\begin{tabular}{| l| l }
${m}$ & Matches m instances of the previous pattern item.\\
${m}?$ & Matches m instances of the previous pattern item.\\
${m,}$ & Matches m or more instances of the previous pattern item.\\
${m,}?$ & Matches m or more instances of the previous pattern item.\\
${m,n}$ & Matches m through n instances of the previous pattern item.\\
${m,n}?$ & Matches m through n instances of the previous pattern item.\\
$*?$ & Matches zero or more instances of the previous pattern item.\\
$+?$ & Matches one or more instances of the previous pattern item.\\
$??$ & Matches zero or one instances of the previous pattern item.\\
$(?:re)$ & Groups a subpattern, re, but does not capture the result.\\
$(?=re)$ & Positive look-ahead. Matches the point where re begins.\\
$(?!re)$ & Negative look-ahead. Matches the point where re does not begin.\\
$(?abc)$ & Embedded options, where abc is any number of option letters.\\
$[: :]$ & Delimits a character class within a bracketed expression.\\
$[. .]$ & Delimits a collating element within a bracketed expression.\\
$[= =]$ & Delimits an equivalence class within a bracketed expression.\\
\end{tabular}
\end{table}
\end{document}
我试过[!ht]
,[!htp]
或者[htpb]
,但这些都不起作用,表格反而消失了。所以请帮忙。
答案1
没有标题 + 没有标题 + 没有浮动 = 对我来说,更像是一个列表,而不是一个表格。
可以使用内置命令或修改列表的包添加任何所需的样式/缩进,例如enumitem
。
与标准tabular
环境不同(尤其是与tabular
包装在table
环境中不同),此解决方案可以跨页面中断。
\documentclass{article}
\begin{document}
\begin{description}
\item{$.$} Matches any character.
\item{$*$} Matches zero or more instances of the previous pattern item.
\item{$+$} Matches one or more instances of the previous pattern item.
\item{$?$} Matches zero or one instances of the previous pattern item.
\item{$(\,)$} Groups a subpattern. The repetition and alternation operators apply to the preceding subpattern.
\item{$|$} Alternation.
\item{$[\,]$} Delimit a set of characters. Ranges are specified as [x-y].
\item{\textasciicircum} Anchor the pattern to the beginning of the string. Only when first.
\item{\$} Anchor the pattern to the end of the string. Only when last.
\end{description}
\end{document}
以下是实现更好对齐的一种可能方法:
\documentclass{article}
\begin{document}
\begin{description}\def\Item#1{\item{\makebox[8pt]{#1}}}
\Item{$.$} Matches any character.
\Item{$*$} Matches zero or more instances of the previous pattern item.
\Item{$+$} Matches one or more instances of the previous pattern item.
\Item{$?$} Matches zero or one instances of the previous pattern item.
\Item{$(\,)$} Groups a subpattern. The repetition and alternation operators apply to the preceding subpattern.
\Item{$|$} Alternation.
\Item{$[\,]$} Delimit a set of characters. Ranges are specified as [x-y].
\Item{\textasciicircum} Anchor the pattern to the beginning of the string. Only when first.
\Item{\$} Anchor the pattern to the end of the string. Only when last.
\end{description}
\end{document}
当然还有无数其他的方法可以实现这一点。