How do I make use of this space after the table?

  • Context: LaTeX 
  • Thread starter Thread starter Wrichik Basu
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary
SUMMARY

The discussion focuses on formatting issues in a LaTeX document, specifically regarding the placement of two NiceTabular environments within a single table environment. Users are seeking a solution to insert space between the two tables without causing them to shift to the next page. The recommended approach involves using the \baselineskip command to adjust spacing effectively. The conversation also highlights the importance of compiling with LuaLaTeX and utilizing the mathsettings package for optimal results.

PREREQUISITES
  • Familiarity with LaTeX document preparation
  • Understanding of the NiceTabular package for table formatting
  • Knowledge of LuaLaTeX compilation process
  • Experience with the mathsettings package for mathematical typesetting
NEXT STEPS
  • Research the usage of the \baselineskip command in LaTeX for spacing adjustments
  • Explore the NiceTabular package documentation for advanced table formatting techniques
  • Learn about LuaLaTeX specific features and advantages over traditional LaTeX
  • Investigate the mathsettings package and its applications in mathematical documents
USEFUL FOR

LaTeX users, document designers, and researchers looking to enhance their table formatting skills and manage spacing effectively in complex documents.

Wrichik Basu
Science Advisor
Insights Author
Gold Member
Messages
2,180
Reaction score
2,690
Without further ado, I'll directly put the MWE here:
[CODE title="LaTeX code"]\documentclass[a4paper, 11pt, draft]{article}

\usepackage{fontspec}
\usepackage{mathsettings}
\usepackage{geometry}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage{layout}
\usepackage{makecell}
\usepackage[none]{hyphenat}
\usepackage{longtable}
\usepackage{pifont}
\usepackage{graphicx}
\usepackage{nicematrix}
\usepackage{xcolor}
\usepackage{makecell}
\usepackage{tablefootnote}
\usepackage{lipsum}

\definecolor{yellowbg}{HTML}{ffd966}
\definecolor{greybg}{HTML}{cccccc}

\setlength{\parindent}{0pt}
\newgeometry{top=2cm,
bottom=2.5cm,
left=2.5cm,
right=2.5cm
}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\arraystretch}{1.5}

\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{20pt}
\fancyhead[C]{\includegraphics[scale=0.2]{Logo}}
\fancyfoot[L]{XYZ 2024}
\fancyfoot[R]{\footnotesize Page~\thepage~of~\pageref*{LastPage}}

\begin{document}

\newgeometry{top=2cm, bottom=1.5cm, left=1.5cm, right=1.5cm}
\setlength{\headheight}{10pt}

\subsection{Analysis}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

\begin{table}[h]
%
\scriptsize\centering
%
\caption{\label{table:sensitivity_reduce}Analysis considering a decrease by 7\%.}
\vspace*{0.5em}
%
\begin{NiceTabular}[corners, hvlines, first-row, code-for-first-row=\bfseries]{lrrrrr}
%
& Year 1 & Year 2 & Year 3 & Year 4 & Year 5 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
\end{NiceTabular}
%
\caption{\label{table:sensitivity_increase}Analysis considering an increase by 7\%.}
\vspace*{0.5em}
%
\begin{NiceTabular}[corners, hvlines, first-row, code-for-first-row=\bfseries]{lrrrrr}
%
& Year 1 & Year 2 & Year 3 & Year 4 & Year 5 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxxxxx xxxxxxx (\textwon) & 111,111,111 & 222,222,222 & 333,333,333 & 444,444,444 & 555,555,555 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
Xxxxx xxxxxx (\%) & 11.11 & 22.22 & 33.33 & 44.44 & 55.55 \\
%
\end{NiceTabular}
%
\end{table}

\end{document}
[/CODE]

Please compile with LuaLaTeX. You can find the mathsettings package here. (If using Overleaf, you can ask Overleaf to directly pull from GitHub.) For the image, please see the third attached image.

The reason there are two NiceTabular environments inside one table environment is that I want to fit both the tables in this page. If I separate them, one table is always going to the second page.

The output looks like this, with the space I am referring to highlighted:

1727121641956.png

If I use \vfill above the table environment, the entire table gets shifted down, as expected:

1727121746099.png

But using \vspace{} or \vspace*{} anywhere between the two NiceTabular environments results in the entire thing going to the next page, even if the space is tiny, like 7pt. The existing space looks far greater than 7pt, though.

Any idea how I can insert some space between the two tables without them going into the next page?
 

Attachments

  • Logo1.png
    Logo1.png
    4.1 KB · Views: 58
Physics news on Phys.org
I am not set up to try out this idea - but can you include a \baselineskip to the "Table" lines?
 
.Scott said:
I am not set up to try out this idea - but can you include a \baselineskip to the "Table" lines?
Sorry for the late response. Did you mean at the end of every line in the table, after the //? Or the table environment? If the latter, how should I add it?
 
I was suggesting adding it in two places: lines 53 and 96. in both cases, just before the \label.
I offer no guarantees. I have worked with rtf files, but not specifically what you are doing. Nor have I tried anything out.
Also, this will take 1 parameter. So, for example, you might try \baselineskip=40pt.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K