mdframed 框包含带文字标题的表格和图形

mdframed 框包含带文字标题的表格和图形

我想创建一个包含任意文本、带标题的表格和带标题的图片的框架。但mdframed不允许里面有浮动。如何实现?像这样的方法不起作用,因为您无法在里面插入浮动mdframed

\begin{mdframed}
\lipsum[4-6]
\begin{figure}\centering{\includegraphics[width=8cm,height=5cm]{exampleimg}\caption{exampleimg}}\end{figure}
\lipsum[1-3]
\end{mdframed}


\begin{mdframed}
\lipsum[4-6]
\begin{threeparttable}
\caption{\label{milk-consumption-india}Asdkj sdlkj sldkjf lskjd flograms per capita per annum}
\begin{center}
\begin{tabulary}{\textwidth}{lrrr}
Year & Rural & Urban & All\\
\hline
1983 & 38.7 & 55.6 & 44.7\\
1993–1994 & 50.3 & 66.4 & 54.3\\
2004–2005 & 50.2 & 69.3 & 55\\
2009–2010 & 51.7 & 71.6 & 57.1\\
\end{tabulary}
\end{center}
\begin{tablenotes}
\item[] \footnotesize Source: \citet{anjani2014}
\end{tablenotes}
\end{threeparttable}
\lipsum[1-3]
\end{mdframed}

如何在框内插入表格或图形mdframed而不使其浮动?

答案1

在 OP 通过评论澄清之后,最好使用\captionoffromcaption包并删除figuretable环境。对于表格注释,可以添加一行,如下所示。

\documentclass{article}
\usepackage{mdframed,graphicx,caption}
\usepackage{lipsum}

\begin{document}
    \begin{mdframed}
      \lipsum[4]
      {\centering
      \includegraphics[width=3cm,height=3cm]{example-image-a}
      \captionof{figure}{exampleimg}
      \par}
      \lipsum[1]
\lipsum[4-6]
\begin{center}
\captionof{table}{\label{milk-consumption-india}Asdkj sdlkj sldkjf lskjd flograms per capita per annum}
\begin{tabular}{lrrr}
  Year        & Rural & Urban & All   \\ \hline
  1983        & 38.7  & 55.6  & 44.7  \\
  1993–1994   & 50.3  & 66.4  & 54.3  \\
  2004–2005   & 50.2  & 69.3  & 55    \\
  2009–2010   & 51.7  & 71.6  & 57.1  \\
  \multicolumn{4}{@{}l@{}}{\footnotesize Source:} %\citet{anjani2014}}
\end{tabular}
\end{center}

\lipsum[1-3]
\end{mdframed}
\end{document}

在此处输入图片描述

相关内容