\begin{longtable}[h]
\small
\singlespacing
\begin{tabular}{l c c l c c}
\hline
\multicolumn{3}{l}{\textbf{Input variables}} & \multicolumn{3}{l}{\textbf{Output variables}} \\
\hline
\textbf{Variable} & \textbf{Unit} & $N_z$ & \textbf{Variable} & \textbf{Unit} & $N_z$ \\
\hline
Temperature & K & 60 & Heating tendency & K s$^{-1}$ & 60 \\
Specific humidity & kg kg$^{-1}$ & 60 & Moistening tendency & kg kg$^{-1}$ s$^{-1}$ & 60 \\
Cloud liquid mixing ratio & kg kg$^{-1}$ & 60 & Cloud liquid mixing ratio tendency & kg kg$^{-1}$ s$^{-1}$ & 60 \\
Cloud ice mixing ratio & kg kg$^{-1}$ & 60 & Cloud ice mixing ratio tendency & kg kg$^{-1}$ s$^{-1}$ & 60 \\
Zonal wind speed & m s$^{-1}$ & 60 & Zonal wind tendency & m s$^{-1}$ s$^{-1}$ & 60 \\
Meridional wind speed & m s$^{-1}$ & 60 & Meridional wind tendency & m s$^{-1}$ s$^{-1}$ & 60 \\
Ozone volume mixing ratio & mol mol$^{-1}$ & 60 & Net surface shortwave flux & W m$^{-2}$ & 1 \\
CH4 volume mixing ratio & mol mol$^{-1}$ & 60 & Downward surface longwave flux & W m$^{-2}$ & 1 \\
N2O volume mixing ratio & mol mol$^{-1}$ & 60 & Snow rate & m s$^{-1}$ & 1 \\
Surface pressure & Pa & 1 & Rain rate & m s$^{-1}$ & 1 \\
Solar insolation & W m$^{-2}$ & 1 & Visible direct solar flux & W m$^{-2}$ & 1 \\
Surface latent heat flux & W m$^{-2}$ & 1 & Near-IR direct solar flux & W m$^{-2}$ & 1 \\
Surface sensible heat flux & W m$^{-2}$ & 1 & Visible diffused solar flux & W m$^{-2}$ & 1 \\
Zonal surface stress & N m$^{-2}$ & 1 & Near-IR diffused solar flux & W m$^{-2}$ & 1 \\
Meridional surface stress & N m$^{-2}$ & 1 & & & \\
Cosine of solar zenith angle & & 1 & & & \\
Albedo for diffuse longwave radiation & & 1 & & & \\
Albedo for direct longwave radiation & & 1 & & & \\
Albedo for diffuse shortwave radiation & & 1 & & & \\
Albedo for direct shortwave radiation & & 1 & & & \\
Upward longwave flux & W m$^{-2}$ & 1 & & & \\
Ice areal fraction & & 1 & & & \\
Land areal fraction & & 1 & & & \\
Sea areal fraction & & 1 & & & \\
Snow depth over ice & m & 1 & & & \\
Snow depth over land & m & 1 & & & \\
\hline
\multicolumn{2}{l}{Size of stacked vectors} & 557 & \multicolumn{2}{l}{} & 368 \\
\hline
\end{tabular}
\caption{Table showing input and output variables, their units, and their number of vertical levels $N_z$ for the original ClimSim paper. \label{tab:inputsoutputs_ClimSim1}}
\end{longtable}
\documentclass{article} % Or your document class (e.g., report, book)
\usepackage{longtable}
\usepackage{ltxtable} % This package combines longtable and tabularx
\usepackage{calc} % For calculations, though maybe not strictly needed for this approach
\usepackage{geometry} % For setting margins easily, useful for testing width
\usepackage{amsmath} % For \text (optional, but good for regular text in math mode)
\usepackage{ragged2e} % For \RaggedRight, etc. (optional, good for general text alignment)
\usepackage{caption} % Recommended for table captions
% Set wider margins for demonstration purposes if needed
\geometry{a4paper, margin=1in}
\begin{document}
% --- Recommended settings for longtables ---
% Set the left margin for longtable to 0pt to make it flush left.
% This needs to be done *before* the longtable environment.
\setlength{\LTleft}{0pt}
% Set the right margin for longtable to fill the remaining space.
% (Often set to \fill to allow automatic width adjustment if not using a fixed width table like ltxtable)
\setlength{\LTright}{0pt} % For ltxtable, this is less critical as \textwidth is given
% It's good practice to ensure text baseline alignment if not full,
% but for ltxtable, it's often not necessary.
% \setlength{\tabcolsep}{6pt} % Default is 6pt, adjust if needed
% For tables that might span multiple pages, raggedbottom can prevent large
% vertical gaps if the table doesn't fill the last page exactly.
\raggedbottom
\begin{ltxtable}{\textwidth}{X c c X c c} % <--- Key changes here!
% \begin{ltxtable}{\textwidth}{...} makes the table exactly \textwidth wide.
% X columns distribute the remaining space equally.
% We use X for the "Variable" columns which contain the most text.
% c for "Unit" and "$N_z$" keeps them compact.
\small
\singlespacing % This applies to the table content
\hline
\multicolumn{3}{l}{\textbf{Input variables}} & \multicolumn{3}{l}{\textbf{Output variables}} \\
\hline
\textbf{Variable} & \textbf{Unit} & $N_z$ & \textbf{Variable} & \textbf{Unit} & $N_z$ \\
\hline
\endhead % Required for longtable to repeat headers on new pages
% Footnote on the last page of the table
\hline
\multicolumn{2}{l}{Size of stacked vectors} & 557 & \multicolumn{2}{l}{} & 368 \\
\hline
\endfoot
% Footnote on every page of the table except the last
\endlastfoot
Temperature & K & 60 & Heating tendency & K s$^{-1}$ & 60 \\
Specific humidity & kg kg$^{-1}$ & 60 & Moistening tendency & kg kg$^{-1}$ s$^{-1}$ & 60 \\
Cloud liquid mixing ratio & kg kg$^{-1}$ & 60 & Cloud liquid mixing ratio tendency & kg kg$^{-1}$ s$^{-1}$ & 60 \\
Cloud ice mixing ratio & kg kg$^{-1}$ & 60 & Cloud ice mixing ratio tendency & kg kg$^{-1}$ s$^{-1}$ & 60 \\
Zonal wind speed & m s$^{-1}$ & 60 & Zonal wind tendency & m s$^{-1}$ s$^{-1}$ & 60 \\
Meridional wind speed & m s$^{-1}$ & 60 & Meridional wind tendency & m s$^{-1}$ s$^{-1}$ & 60 \\
Ozone volume mixing ratio & mol mol$^{-1}$ & 60 & Net surface shortwave flux & W m$^{-2}$ & 1 \\
CH4 volume mixing ratio & mol mol$^{-1}$ & 60 & Downward surface longwave flux & W m$^{-2}$ & 1 \\
N2O volume mixing ratio & mol mol$^{-1}$ & 60 & Snow rate & m s$^{-1}$ & 1 \\
Surface pressure & Pa & 1 & Rain rate & m s$^{-1}$ & 1 \\
Solar insolation & W m$^{-2}$ & 1 & Visible direct solar flux & W m$^{-2}$ & 1 \\
Surface latent heat flux & W m$^{-2}$ & 1 & Near-IR direct solar flux & W m$^{-2}$ & 1 \\
Surface sensible heat flux & W m$^{-2}$ & 1 & Visible diffused solar flux & W m$^{-2}$ & 1 \\
Zonal surface stress & N m$^{-2}$ & 1 & Near-IR diffused solar flux & W m$^{-2}$ & 1 \\
Meridional surface stress & N m$^{-2}$ & 1 & & & \\
Cosine of solar zenith angle & & 1 & & & \\
Albedo for diffuse longwave radiation & & 1 & & & \\
Albedo for direct longwave radiation & & 1 & & & \\
Albedo for diffuse shortwave radiation & & 1 & & & \\
Albedo for direct shortwave radiation & & 1 & & & \\
Upward longwave flux & W m$^{-2}$ & 1 & & & \\
Ice areal fraction & & 1 & & & \\
Land areal fraction & & 1 & & & \\
Sea areal fraction & & 1 & & & \\
Snow depth over ice & m & 1 & & & \\
Snow depth over land & m & 1 & & & \\
% The \endfoot and \endlastfoot commands above replace the final \hline and final row.
\caption{Table showing input and output variables, their units, and their number of vertical levels $N_z$ for the original ClimSim paper. \label{tab:inputsoutputs_ClimSim1}}
\end{ltxtable}
\end{document}