在 itemize 环境中插入带标题的表格

在 itemize 环境中插入带标题的表格

我正在尝试在 itemize 环境中插入一个带标题的表格。但是我找不到将标题和表格本身与外部环境的边框对齐的方法。

我已经尝试过scalebox、、、parbox..minipage以及captionof..但仍然找不到使其适合的方法。

这是我的代码:

\documentclass[a4paper,12pt]{report}
\setlength{\paperheight}{297mm}
\setlength{\paperwidth}{210mm}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage[italian]{babel}
\usepackage[margin=1.2in]{geometry}
\usepackage{blkarray}
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
\begin{document}

\begin{itemize}
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis laoreet nunc. Integer vel turpis ut odio viverra malesuada. Pellentesque est leo, scelerisque eget eros eget, finibus luctus felis.
    \begin{table}[ht]
        \centering
        \resizebox{.85\textwidth}{!}{
            \begin{tabular}{|l|l|l|l|l|l|l|l|}
                \hline
                Type       & PCB & PCB & PCB & PCB & PCB & PCB & PCB \\ \hline
                Number     & 1   & 1   & 1   & 1   & 1   & 1   & 1   \\ \hline
                Number two & \multicolumn{7}{c|}{6}                  \\ \hline
            \end{tabular}
        }
        \caption{Cras sit amet leo ante. Nunc condimentum magna non ornare dignissim. Curabitur vitae porta nisi. Nunc tempor, diam non tempor suscipit, nulla nisl porta dui, in consectetur odio odio vitae magna.}
        \label{tabelladeltageopcb}
        \end{table}
        Fusce dignissim quis enim eget posuere. Nullam suscipit pulvinar magna sed pharetra. In in auctor nulla. Etiam in quam vitae dui luctus pellentesque ac vitae quam.
    \end{itemize}
\end{document}

提前致谢

答案1

环境的唯一目的table是允许 latex 浮动表格,因此在这里您想要它在列表中的位置,您不希望table

在此处输入图片描述

\documentclass[a4paper,12pt]{report}
\setlength{\paperheight}{297mm}
\setlength{\paperwidth}{210mm}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage[italian]{babel}
\usepackage[margin=1.2in]{geometry}
\usepackage{blkarray}
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
\begin{document}

\begin{itemize}
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis laoreet nunc. Integer vel turpis ut odio viverra malesuada. Pellentesque est leo, scelerisque eget eros eget, finibus luctus felis.

\begin{minipage}{\linewidth}
            \begin{tabular}{|l|l|l|l|l|l|l|l|}
                \hline
                Type       & PCB & PCB & PCB & PCB & PCB & PCB & PCB \\ \hline
                Number     & 1   & 1   & 1   & 1   & 1   & 1   & 1   \\ \hline
                Number two & \multicolumn{7}{c|}{6}                  \\ \hline
            \end{tabular}

        \captionof{table}{Cras sit amet leo ante. Nunc condimentum magna non ornare dignissim. Curabitur vitae porta nisi. Nunc tempor, diam non tempor suscipit, nulla nisl porta dui, in consectetur odio odio vitae magna.}
        \label{tabelladeltageopcb}
\end{minipage}

        Fusce dignissim quis enim eget posuere. Nullam suscipit pulvinar magna sed pharetra. In in auctor nulla. Etiam in quam vitae dui luctus pellentesque ac vitae quam.
    \end{itemize}
\end{document}

答案2

以下是使用列表参数和threeparttable环境的方法:

\documentclass[a4paper,12pt]{report}
\setlength{\paperheight}{297mm}
\setlength{\paperwidth}{210mm}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage[italian]{babel}
\usepackage[margin=1.2in]{geometry}
\usepackage{blkarray}
\usepackage{float}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{threeparttable}
\begin{document}

\begin{itemize}
    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis laoreet nunc. Integer vel turpis ut odio viverra malesuada. Pellentesque est leo, scelerisque eget eros eget, finibus luctus felis.
    \begin{table}[ht]
        \centering
        \hskip\leftmargin\begin{threeparttable}
            \begin{tabular}{|l|*{7}{c|}}
                \hline
                Type & PCB & PCB & PCB & PCB & PCB & PCB & PCB \\ \hline
                Number & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ \hline
                Number two & \multicolumn{7}{c|}{6} \\ \hline
            \end{tabular}
    \caption{Cras sit amet leo ante. Nunc condimentum magna non ornare dignissim. Curabitur vitae porta nisi. Nunc tempor, diam non tempor suscipit, nulla nisl porta dui, in consectetur odio odio vitae magna.}
        \label{tabelladeltageopcb}
    \end{threeparttable}
    \end{table}
        Fusce dignissim quis enim eget posuere. Nullam suscipit pulvinar magna sed pharetra. In in auctor nulla. Etiam in quam vitae dui luctus pellentesque ac vitae quam.
    \end{itemize}

\end{document} 

在此处输入图片描述

相关内容