General ⇒ latex table problem --about >{\centering}
-
- Posts: 2
- Joined: Thu Oct 09, 2008 6:28 am
latex table problem --about >{\centering}
\begin{tabular}{|c |>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|}
[29-32, 34-36] & & \Checkmark & & & & &\Checkmark \\
\hline
\end{tabular}
the error indicated is "! Misplaced \noalign. \hline -> \noalign"
However, if I change this code to:
\begin{tabular}{|c |>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|}
[29-32, 34-36] & & \Checkmark & & & & &\\
\hline
\end{tabular}
or
\begin{tabular}{|c |>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|>{\centering}m{1.2 cm}|m{1.2 cm}|} %the last column without centering horizontally
[29-32, 34-36] & & \Checkmark & & & & &\Checkmark \\
\hline
\end{tabular}
No error occurs.
Can you help me fix it? Besides, why is there a ">" in this command ">{\centering}" ?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
latex table problem --about >{\centering}
The array package redefines \\ (the command to change line). To avoid the error that you are getting there are two options:
1) Instead of \\ you can use \tabularnewline, as the following example suggests:
Code: Select all
\documentclass{article}
\usepackage{bbding}
\usepackage{array}
\begin{document}
\begin{tabular}{|c*{7}{|>{\centering}m{1.2 cm}}|}
[29-32, 34-36] & & \Checkmark & & & & & \Checkmark \tabularnewline
\hline
\end{tabular}
\end{document}
Code: Select all
\documentclass{article}
\usepackage{bbding}
\usepackage{array}
\begin{document}
\begin{tabular}{|c*{7}{|>{\centering\arraybackslash}m{1.2 cm}}|}
[29-32, 34-36] & & \Checkmark & & & & & \Checkmark \\
\hline
\end{tabular}
\end{document}
-
- Posts: 2
- Joined: Thu Oct 09, 2008 6:28 am