0

Using the following code, I can not figure out why the last column text is not displayed when using the code

\centering {\textcolor{black} {\bf receptors}}`

giving the error message

! Misplaced \noalign.
\hline ->\noalign 
{\ifnum 0=`}\fi \penalty \@M \futurelet \@let@token \LT@@h...
l.38     \end{frame}
?

but it only could be displayed when using the code

\multicolumn{1}{c|}{\parbox {.29\textwidth}{\centering {\textcolor{black} {\bf receptors}}}}

MWE:

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{verbatim}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage{multicol}
\usepackage{multirow}
\begin{document}
\begin{frame}[t]
\frametitle{\bf Types of ...}
\begin{table}
\begin{minipage}[c]{1.\textwidth}
{
\begin{center}
\begin{longtable}[!htp]{|m{.16\textwidth}|m{.16\textwidth}|m{.28\textwidth}|}\hline
\centering {\textcolor{black} {\bf hello}} & 
\centering {\textcolor{blue} {\bf hello}}\\
{\textcolor{green} {\bf hello}} &
%\centering {\textcolor{black} {\bf receptors}}
\multicolumn{1}{c|}{\parbox {.29\textwidth}{\centering {\textcolor{black} {\bf receptors}}}}
\\ \hline
\centering {\textcolor{black} {\bf hello}} & 
\centering {\textcolor{blue} {\bf hello}}\\
{\textcolor{green} {\bf hello}} &
\\ \hline
\centering {\textcolor{black} {\bf hello}} & 
\centering {\textcolor{blue} {\bf hello}}\\
{\textcolor{green} {\bf hello}} &
\\ \hline
\end{longtable}
\end{center}
}
\end{minipage}
\end{table}
\end{frame}
\end{document} 

enter image description here

6
  • You should not use deprecated font commands such as \bf, see tex.stackexchange.com/questions/516/… Oct 5, 2018 at 10:22
  • The code might be ugly, but compiles fine for me without error. Oct 5, 2018 at 10:25
  • did you use \centering {\textcolor{black} {\bf receptors}} instead of using \multicolumn{1}{c|}{\parbox {.29\textwidth}{\centering {\textcolor{black} {\bf receptors}}}}
    – Hany
    Oct 5, 2018 at 10:27
  • Please make a MWE that actually reproduces the error. Oct 5, 2018 at 10:29
  • just uncomment the line \centering {\textcolor{black} {\bf receptors}}, and comment the line \multicolumn{1}{c|}{\parbox {.29\textwidth}{\centering {\textcolor{black} {\bf receptors}}}}
    – Hany
    Oct 5, 2018 at 10:31

1 Answer 1

2

The code seems unnecessarily complicate, I'd write the table like this:

\documentclass{beamer}

\setbeamertemplate{navigation symbols}{}
\setbeamerfont{frametitle}{series=\bfseries}

\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}

\begin{frame}[t]
\frametitle{Types of ...}
\begin{table}
    \bfseries
    \begin{tabular}{|C{.16\textwidth}|C{.16\textwidth}|C{.28\textwidth}|}
        \hline
        hello & \textcolor{blue}{hello} \textcolor{green}{hello} & receptors\\ \hline
        hello & \textcolor{blue}{hello} \textcolor{green}{hello} & \\ \hline
        hello & \textcolor{blue}{hello} \textcolor{green}{hello} & \\ \hline
    \end{tabular}
\end{table}
\end{frame}

\end{document} 

Please note the following changes:

  • \bf is deprecated and should no longer be used.

  • You should not use formatting instructions in arguments of macros like \frametitle. If you want to change the font, use \setbeamerfont{frametitle}{series=\bfseries}

  • nesting a table, a minipage, a group, a center environment and a longtable is really overkill. Tables are centred by default in beamer, and the minipage and the group don't do anything useful. Also you are not using any special features of the longtable

  • Beamer does not have floats, it makes no sense to specify floating specifier

  • \centering is a switch, it does not take arguments.

enter image description here

7
  • Thank you very much for your answer. Could you please tell me what was wrong in the code I used.
    – Hany
    Oct 5, 2018 at 10:43
  • @Hany \centering redefines what \\ means, which also explains why it is only a problem in the lat column. The trick is also using \arraybackslash which reverts the table/array meaning of \\ as the ender of a row\
    – daleif
    Oct 5, 2018 at 10:59
  • @samcarter Thank you very much for your explanation.
    – Hany
    Oct 5, 2018 at 12:31
  • @samcarter Please just one comment. I used m option to vertically align text inside cells; but your fine code does not allow this. Text is still top aligned.
    – Hany
    Oct 5, 2018 at 14:07
  • @Hany If you look at my code, you'll see that I also use the m column. Also as you can see in my screenshot the text is not top aligned! Oct 5, 2018 at 14:09

You must log in to answer this question.

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