To adjust your LaTeX table so that it exactly fits the text width, you can use the tabularx package, which allows you to create tables with columns that automatically adjust their widths to fill the available space. Here's how you can modify your code:
-
Include the tabularx package in your preamble:
\usepackage{tabularx}
-
Modify your table to use tabularx and define flexible columns:
Replace your tabular environment with tabularx, specify the total width as \textwidth, and use the X column type for columns that should adjust their widths.
\begin{table*}[htbp]
\centering
\caption{Summary of published EEG databases for emotion recognition/classification.}
\label{tab:related_works}
\begin{tabularx}{\textwidth}{lccXXl}
\toprule
\textbf{Dataset} & \textbf{EEG Electrodes} & \textbf{Participants} & \textbf{Stimuli} & \textbf{Emotion Labels} & \textbf{Devices} \\ \midrule
DEAP~\cite{koelstra2011deap} & 32 & 32 & Music videos & Arousal, Valence, Dominance, Liking & Biosemi ActiveTwo \\
MAHNOB~\cite{soleymani2011multimodal} & 32 & 30 & Movie clips & Disgust, Amusement, Fear, Sadness, Joy & 32-channel EEG + ECG + EDA \\
SEED~\cite{zheng2015investigating} & 62 & 15 & Film clips & Positive, Negative, Neutral & 62-channel EEG \\
MPED~\cite{song2019mped} & 62 & 23 & Emotion videos & Joy, Anger, Fear, Disgust, Sadness, Neutrality & 62-channel EEG \\
DREAMER~\cite{katsigiannis2017dreamer} & 14 & 23 & Audio-visual clips & Valence, Arousal, Dominance & Emotiv EPOC \\ \bottomrule
\end{tabularx}
\end{table*}
Explanation of the column types:
lccXXl means:
l: Left-aligned column for the Dataset.
c: Centered column for EEG Electrodes.
c: Centered column for Participants.
X: Flexible-width column for Stimuli.
X: Flexible-width column for Emotion Labels.
l: Left-aligned column for Devices.
The X columns will expand or shrink to ensure the table fits exactly within \textwidth.
-
Adjust column alignment if needed:
If you prefer different alignments for the flexible columns, you can define custom column types:
\newcolumntype{Y}{>{\centering\arraybackslash}X} % Centered X column
\newcolumntype{Z}{>{\raggedright\arraybackslash}X} % Left-aligned X column
Then, you can use Y or Z instead of X in your tabularx definition:
\begin{tabularx}{\textwidth}{lccYYl}
-
Ensure consistent vertical spacing:
Replace \hline with \midrule and \toprule/\bottomrule from the booktabs package for better-looking horizontal lines (if not already included):
\usepackage{booktabs}
-
Compile your document:
After making these changes, compile your LaTeX document. Your table should now exactly fit the text width without overflowing the margins.
Final Code Example:
\documentclass[twocolumn]{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array} % For the new column types
\usepackage{cite} % If you're using citations
% Define new column types for alignment
\newcolumntype{Y}{>{\centering\arraybackslash}X} % Centered X column
\newcolumntype{Z}{>{\raggedright\arraybackslash}X} % Left-aligned X column
\begin{document}
\begin{table*}[htbp]
\centering
\caption{Summary of published EEG databases for emotion recognition/classification.}
\label{tab:related_works}
\begin{tabularx}{\textwidth}{lccYYl}
\toprule
\textbf{Dataset} & \textbf{EEG Electrodes} & \textbf{Participants} & \textbf{Stimuli} & \textbf{Emotion Labels} & \textbf{Devices} \\ \midrule
DEAP~\cite{koelstra2011deap} & 32 & 32 & Music videos & Arousal, Valence, Dominance, Liking & Biosemi ActiveTwo \\
MAHNOB~\cite{soleymani2011multimodal} & 32 & 30 & Movie clips & Disgust, Amusement, Fear, Sadness, Joy & 32-channel EEG + ECG + EDA \\
SEED~\cite{zheng2015investigating} & 62 & 15 & Film clips & Positive, Negative, Neutral & 62-channel EEG \\
MPED~\cite{song2019mped} & 62 & 23 & Emotion videos & Joy, Anger, Fear, Disgust, Sadness, Neutrality & 62-channel EEG \\
DREAMER~\cite{katsigiannis2017dreamer} & 14 & 23 & Audio-visual clips & Valence, Arousal, Dominance & Emotiv EPOC \\ \bottomrule
\end{tabularx}
\end{table*}
\end{document}
Notes:
- Adjust the column alignments (
l, c, Y, Z, X) as needed to suit your content.
- The
twocolumn option in \documentclass is included assuming you're working with a two-column layout.
- Make sure all packages used (
tabularx, booktabs, etc.) are included in your preamble.
By following these steps, your table should now perfectly fit within the text width of your document.