LaTeX forum ⇒ Text FormattingFit Tables or pictures into list items

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Jan Borowiec
Posts: 5
Joined: Sun Aug 09, 2020 9:31 pm

Fit Tables or pictures into list items

Postby Jan Borowiec » Mon Aug 17, 2020 11:44 pm

I often need to create a table or picture in a list item. The result is that such a table or picture behaves as
if it were no part of the list and uses the whole pages textwidth.
What shall I do to solve this problem.
Best regards, Jan

Example:
\NeedsTeXFormat{LaTeX2e}
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\pagestyle{empty}

\begin{document}

\paragraph{sample.}\ \ 
Level 1
\begin{enumerate}
  \item Level 2-1
    \begin{itemize}
      \item Level 3-1
      \item Level 3-2
        \begin{table}[thb]
          \begin{tabular}{|c|c|c|c|} \hline
                  AAAAAA & BBBBBB & CCCCCC & DDDDDD \\ \hline
          \end{tabular}
          \caption{Triumph! Triumpf! Du edles Paar!
           Besieget hast du die Gefahr!
           Der Isis Weihe ist nun dein!
           Kommt, kommt, tretet in den Tempel ein!}
        \end{table}
      \item Level 3-3
    \end{itemize}
  \item Level 2-2
\end{enumerate}
\end{document}
Last edited by cgnieder on Sun Aug 23, 2020 8:13 pm, edited 1 time in total.

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
Bartman
Posts: 309
Joined: Fri Jan 03, 2020 2:39 pm

Fit Tables or pictures into list items

Postby Bartman » Tue Aug 18, 2020 1:09 am

You could have simply added the example to your older topic instead of starting a new one for the same problem.

\documentclass[a4paper]{article}
%\usepackage[utf8]{inputenc}% issue 28 in ltnews on CTAN
\usepackage[T1]{fontenc}
\usepackage{caption}% needed for \captionof command
\usepackage{showframe}% shows the page layout

\pagestyle{empty}

\begin{document}
\paragraph{sample.} Level 1
\begin{enumerate}
    \item Level 2-1
    \begin{itemize}
        \item Level 3-1
        \item Level 3-2

        \medskip
        \begin{minipage}{\linewidth}
            \begin{tabular}{|*4{c|}} \hline
            AAAAAA & BBBBBB & CCCCCC & DDDDDD \\ \hline
            \end{tabular}
            \captionof{table}{Triumph! Triumpf! Du edles Paar!
            Besieget hast du die Gefahr!
            Der Isis Weihe ist nun dein!
            Kommt, kommt, tretet in den Tempel ein!}
        \end{minipage}
        \item Level 3-3
    \end{itemize}
    \item Level 2-2
\end{enumerate}
\end{document}



Read the LaTeX2e unofficial reference manual to find out what the \NeedsTeXFormat command does before you use it (from a template).

I'd also like to recommend checking out the booktabs package.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests