1

How can i stop my table in latex to start unnecessarily from next page leaving a huge space in previous page? How can i force to start just after the heading. Please help, here is my code: i am using packages:

\usepackage{tabularx,ragged2e,booktabs,caption},
\usepackage{float}

and the code for my table is:

\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}

I tried [!ht], [!htp] or [htpb], but nothing of that sort works instead the table vanishes. So please help.

9
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – Sverre
    Commented Apr 15, 2015 at 10:51
  • Generally, if you don't want huge spaces on the page, don't use H because it defeats one of LaTeX's main mechanisms for producing nice page breaks: the ability to float (move) figures and tables around the document. Commented Apr 15, 2015 at 10:53
  • actually i am making a report and have a long code but my problem is the table starts from next page when there is already space left in the previous page Commented Apr 15, 2015 at 10:53
  • what to use instead of [H] Commented Apr 15, 2015 at 10:54
  • 2
    You have used [H]: the only purpose of that is to say that you don't want the table to float even if it makes a horrible page break leaving large white space, Commented Apr 15, 2015 at 11:29

1 Answer 1

0

No caption + No headings + No floating = Smells like a list to me, rather than a table.

Any desired styling/indentation can be added using built-in commands or a package for modifying lists such as enumitem.

This solution can break across pages, unlike a standard tabular environment (especially unlike a tabular wrapped in a table environment).

\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}

enter image description here

Here's one possible way of achieving a nicer alignment:

\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}

enter image description here

There are of course innumerable other ways to do it.

6
  • but i want it like a table and that too without the problem it is causing that- leaving extra spaces in previous page starting from a new page,is there no way to sort it? Commented Apr 15, 2015 at 11:35
  • @Soumyashree as mentioned in the comments, let the table float if you really want it to be a table. But as I said, there's really no reason for it to be a table. Commented Apr 15, 2015 at 11:42
  • @PaulGessler -- the start of the text for the various \items is very ragged. if these were uniformly indented to the same starting point as the second line of the two-line description, it would look more like a table. the tabbing environment might be an alternative. Commented Apr 15, 2015 at 16:32
  • @barbarabeeton as mentioned in my answer, there are many ways to customize the styling/alignment, which I did not cover here. The point of the post was that it really shouldn't be done as a table in the first place. Commented Apr 15, 2015 at 16:39
  • @PaulGessler -- i agree with the contention that this shouldn't really be done as a table. i was only trying to point out that the raggedy appearance of the result you show wouldn't likely be found attractive enough for someone to take the answer seriously. Commented Apr 15, 2015 at 16:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .