2

Thanks to this answer I can create left justified fixed width columns in my table. However, I would like to ask if anyone else has encountered the problems with the last column not working as it should, for example:

\begin{table}
\caption{Device technical specifications summary.}
\begin{tabular}{|R{3cm}|R{2cm}|R{2cm}|R{2cm}|R{3cm}|}
\hline
~ & Samsung Galaxy Pocket Neo & Samsung S3 Mini & Vodafone Smart4 Mini & Google (Asus) Nexus 7 (2012) \\
\hline
CPU Speed [MHz] & 850 & 1000 & 1300  & 1200 \\
\hline
CPU Type & 1 Core & 2 Core Coretex-A9 & 2 Core Cortex-A7 & 4 Core Cortex-A9 \\
\hline
RAM [MB] & 512 & 1024 & 512 & 1024 \\ 
\hline
Release Year & 2013 & 2012 & 2014 & 2012 \\
\hline
\end{tabular}
\label{Device technical specifications summary}
\end{table}

Everything works fine with \begin{tabular}{|R{3cm}|R{2cm}|R{2cm}|R{2cm}|p{3cm}|}

But if as it was set out above, I get:

Errors: ./contents/Chap-6.tex:40: Misplaced \noalign. [\hline]

i.e. giving me problems starting with the first \hline.

Any advice?

3
  • Welcome to TeX.SX! I'm sorry, but I get no error. Please make a full example.
    – egreg
    Sep 17, 2015 at 14:12
  • Welcome to TeX.SX! I can compile this table after adding the necessary stuff around it. Off-topic: The \label should be placed rather immediately after \caption, not some lines later
    – user31729
    Sep 17, 2015 at 14:12
  • How is the R column type defined?
    – Mico
    Nov 16, 2015 at 16:46

1 Answer 1

1

This works fine for me: (copied the column types verbatim from the link you provided, which I presume is what you did)

\documentclass{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


\begin{document}

\begin{table}
\caption{Device technical specifications summary.\label{Device technical specifications summary}}
\begin{tabular}{|R{3cm}|R{2cm}|R{2cm}|R{2cm}|R{3cm}|}
\hline
~ & Samsung Galaxy Pocket Neo & Samsung S3 Mini & Vodafone Smart4 Mini & Google (Asus) Nexus 7 (2012) \\
\hline
CPU Speed [MHz] & 850 & 1000 & 1300  & 1200 \\
\hline
CPU Type & 1 Core & 2 Core Coretex-A9 & 2 Core Cortex-A7 & 4 Core Cortex-A9 \\
\hline
RAM [MB] & 512 & 1024 & 512 & 1024 \\ 
\hline
Release Year & 2013 & 2012 & 2014 & 2012 \\
\hline
\end{tabular}
\end{table}

\end{document}
2
  • I forgot to add: \newcolumntype{R}[1]{>{\raggedleft}m{#1}} above my table in the question. I don't really see what is so different from \newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} except for the newline part. Anyways, it worked! Thanks!
    – DanielS
    Sep 17, 2015 at 16:19
  • 1
    @DanielS The \arraybackslash bit is crucial; I don't think \let\newline\\ does any good (just avoid using \newline anywhere).
    – egreg
    Feb 14, 2016 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .