I am having some problems with LaTeX tables. In particular, I have the following code:
\begin{table}[ht]
\centering
\setlength{\tabcolsep}{2pt}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}>{\centering}p{0.15\textwidth}p{0.15\textwidth}|}
\hline
& \textbf{Virtual Reality Experience} & \textbf{First Person Experience} & \textbf{Multimedia Presentation Experience} & \multicolumn{2}{c|}{\textbf{Full sample}} \\
\hline
& \textit{n} & \textit{n} & \textit{n} & \textit{n} & \textit{\%} \\
\hline
\textbf{Gender} &&&&& \\
Female & 12 & 10 & 18 & 40 & 52.6 \\
Male & 10 & 13 & 13 & 36 & 47.4 \\
\hline
\textbf{Educational level} &&&&& \\
High School & 8 & 5 & 6 & 19 & 25.0 \\
Bachelor's Degree & 13 & 9 & 19 & 41 & 53.9 \\
Master's Degree & 1 & 8 & 6 & 15 & 19.7 \\
PhD & 0 & 1 & 0 & 1 & 1.3 \\
\hline \hline
\textbf{Age} &&&&& \\
Mean & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
Median & 23.6 & 24.6 & 24 & \multicolumn{2}{c|}{24.1} \\
\hline
\end{tabular}
\caption{Participants demographic information}
\label{tab:demographic}
\end{table}
This code gives me the following output: generated table.
I would like to center also the last column (using, like in the other columns, >{\centering}
). However, when I try to do so, I have a lot of errors:
-
Misplaced
\noalign
- You have used a\hline
command in the wrong place, probably outside a table. If the\hline
command is written inside a table, try including\\
before it (on the 3rd\hline
) -
Extra alignment tab has been changed to
\cr
- You have written too many alignment tabs in a table, causing one of them to be turned into a line break. Make sure you have specified the correct number of columns in your table (on the\textbf{Gender}
line) -
LaTeX Error: There's no line here to end - You have used a
\\
or\newline
command where LaTeX was not expecting one. Make sure that you only use line breaks after blocks of text, and be careful using linebreaks inside lists and other environments (on the\textbf{Gender}
line)
Could anyone help me? The table is far more beautiful if I manage to center also the last line.