1. Sper

Hi Tom,

I’m trying to wrap the contents of some cells of a table without much luck.
Here’s my table, and the solution I am currently using:

\documentclass[12pt,oneside]{book}
\begin{document}
\begin{table}[!h]
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
SNR &amp;amp; \multicolumn{4}{|c|}{Relative error re } \\
\cline{2-5}
in gradient &amp;amp; method number 1 &amp;amp; method number 2 &amp;amp; method number 3 &amp;amp; method number 4\\ \hline\hline
12.5186 &amp;amp; 0.0260 &amp;amp; 0.1063 &amp;amp; 0.0314 &amp;amp; 0.0287 \\ \hline
\end{tabular}
\end{table}
This text is added to highlight the fact that the table exceeds the page margins. What would be a smarter way to wrap some cells (namely, my headers) in such a way that the overall table stays within the page margins? Thanks!
\end{document}

Could you please let me know if there is an easier way of getting the same result, without shrinking the size of the characters?

I hope pasting directly from LaTeX is okay, it’s the best way in which I could think of showing you my problem.

Thank you kindly for taking the time!

Sper

• Hi Sper,

Thank you for the code, that made things a lot easier. I suggest using the fixed width column type m. You’ll find your code below with some changes. First, define a new columntype that is centered horizontally (m) and vertically (centering). Replace \\ by \tabularnewline to avoid “Missplaced \noalign” errors. And, use *{number}{type} to avoid repeating the same columntype over and over again.

\documentclass[12pt,oneside]{book}
\usepackage{array}
\newcolumntype{M}{&gt;{\centering}m{2cm}}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{*{5}{|M}|}
\hline
SNR &amp;amp; \multicolumn{4}{|c|}{Relative error re }
\tabularnewline
\cline{2-5}
in gradient &amp; method number 1 &amp; method number 2 &amp; method number 3 &amp; method number 4 \tabularnewline
\hline\hline
12.5186 &amp; 0.0260 &amp; 0.1063 &amp; 0.0314 &amp; 0.0287 \tabularnewline
\hline
\end{tabular}
\caption{bla}
\end{table}
This text is added to highlight the fact that the table exceeds the page margins. What would be a smarter way to wrap some cells (namely, my headers) in such a way that the overall table stays within the page margins? Thanks!
\end{document}

Best, Tom.

• Sper

Thanks a lot, Tom, for taking the time. I’ll give it a try and see how it works.

Sper

3. Signor D

Thank you, just what I was looking for!

D

4. I’m trying to use a graphic alongside a numbered list, but it just dumps the graphic at the end of the file. This is my code –

\begin{wrapfigure}{r}{0.5\linewidth}
\centering
% \rule{0.9\linewidth}{0.75\linewidth}
\includegraphics{images/bse1.png}
\caption{Dummy figure.}
\label{fig:myfig}
\end{wrapfigure}

\begin{enumerate}
\item Lie down. Flatten your right breast by placing a pillow under your right
\end{enumerate}

How can I do it please Tom?
Sharon.

• tom

Try the minipage environment:

\documentclass[11pt]{article}
\begin{document}

\begin{minipage}{0.45\linewidth}
\rule{0.75\linewidth}{0.75\linewidth}
\end{minipage}
\begin{minipage}{0.45\linewidth}
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
\end{minipage}

\end{document}
5. How do i use the wrapfigure in the report.?

• tom

Hi there,

It works exactly the same way as shown in the example for article. Just give it a try and let me know if you get stuck.

Best, Tom