我需要在mdframed
环境中有带标题的表格。由于不能使用浮点数,因此我将captionof
与一起使用tabular
。当有分页符时(如下面的 MWE 所示),标题和tabular
可能会分开。为了防止这种情况发生,我将它们放在里面minipage
。但minipage
会抓取mdframed
脚注。
梅威瑟:
\documentclass{article}
\usepackage{mdframed}
\usepackage{caption}
\usepackage{lipsum}
\newenvironment{ProblemStatement}{
\mdfsetup{
innertopmargin=10pt,
linewidth=0.4pt
}
\begin{mdframed}[]
}
{
\end{mdframed}
\bigskip
}
\begin{document}
% text
\begin{ProblemStatement}
Blah\footnote{footnote}
\lipsum[1-4]
\begin{minipage}{\textwidth}
\begin{center}
\captionof{table}{My table}
\begin{tabular}{|c|c|}
\hline
1& a \\
\hline
2& b \\
\hline
3& c \\
\hline
4& d \\
\hline
5& e \\
\hline
6& f \\
\hline
7& g \\
\hline
\end{tabular}
\end{center}
\end{minipage}
\lipsum[5-6]
\end{ProblemStatement}
\end{document}
tabular
除了使用 之外,还有其他方法让标题和保持在一起minipage
吗? 有没有办法阻止minipage
抓取脚注? 有没有其他方法可以替代mdframed
,让浮动可以自由使用?
编辑
可以用xepersian
's来做到这一点吗LTRfootnote
?
MWE 2 (带有 XePersian)
\documentclass{article}
\usepackage{mdframed}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{xepersian}
\settextfont{Nazli}
\setlatintextfont{Liberation Serif}
\begin{document}
\begin{mdframed}
Blah\footnote{پانویس}\LTRfootnote{footnote}
\begin{LTR}
\lipsum[1-5]
\end{LTR}
\begin{minipage}{\textwidth}
\begin{center}
\captionof{table}{جدول من}
\begin{tabular}{|c|c|}
\hline
1& a \\
\hline
2& b \\
\hline
\end{tabular}
\end{center}
\end{minipage}
\begin{LTR}
\lipsum[5-6]
\end{LTR}
\end{mdframed}
\end{document}
答案1
mdframed
与 共享脚注内部宏minipage
,因此脚注在 内部收集mdframed
并由 输出minipage
。以下示例利用mdframed
其单独的脚注内部,因此避免了该问题。
\documentclass{article}
\usepackage{mdframed}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{xepersian}
\settextfont{Nazli}
\setlatintextfont{Liberation Serif}
\makeatletter
% emulate mpfootnote staff
\newinsert\@mdf@footins
\@definecounter{mdf@footnote}
\def\themdf@footnote{%
% Currently, both LTR and RTL footnote numbers inside mdframed env are in
% persian format, which raises errors like
% "missing character <persian char> in font <latin font>"
% in LTR footnotes. This might be a bug in my code, and I add \rl as a
% workaround to force using persian text font for all footnote numbers.
\rl{\itshape\@alph\c@mdf@footnote}}
\@ifpackageloaded{bidi}{
\def\bidi@mdf@footnoterule{\footnoterule}
\renewrobustcmd*\mdf@footnoteoutput{%
\ifvoid\@mdf@footins\else
\nobreak
\vskip\mdf@footenotedistance@length
\normalcolor
\mdf@footnoterule
\unvbox\@mdf@footins
\fi
}
\renewrobustcmd*\mdf@footnoteinput{%
\def\@mpfn{mdf@footnote}%
\def\thempfn{\themdf@footnote}%
\c@mdf@footnote\z@
\let\@footnotetext\@mdf@footnotetext
\let\@LTRfootnotetext\@mdf@LTRfootnotetext
\let\@RTLfootnotetext\@mdf@RTLfootnotetext
}
% similar to \@mpTRLfootnotetext defined in footnote-xetex-bidi.def
\long\def\@mdf@RTLfootnotetext#1{%
\ifbidi@autofootnoterule\ifnum\c@mdf@f@footnote=\@ne\global\let\bidi@mdf@footnoterule\right@footnoterule\fi\fi%
\global\setbox\@mdf@footins\vbox{\@RTLtrue%
\unvbox\@mdf@footins
\reset@font%
\bidi@@RTLfootnotetext@font% \reset@font\footnotesize
\hsize\columnwidth
\@parboxrestore
\protected@edef\@currentlabel
{\csname p@mdf@footnote\endcsname\@thefnmark}%
\color@begingroup
\@makefntext{%
\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
\color@endgroup}}
% similar to \@mpLTRfootnotetext defined in footnote-xetex-bidi.def
\long\def\@mdf@LTRfootnotetext#1{%
\ifbidi@autofootnoterule\ifnum\c@mdf@footnote=\@ne\global\let\bidi@mdf@footnoterule\left@footnoterule\fi\fi%
\global\setbox\@mdf@footins\vbox{\@RTLfalse%
\unvbox\@mdf@footins
\reset@font%
\bidi@@LTRfootnotetext@font% \reset@font\footnotesize
\hsize\columnwidth
\@parboxrestore
\protected@edef\@currentlabel
{\csname p@mdf@footnote\endcsname\@thefnmark}%
\color@begingroup
\@makefntext{%
\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
\color@endgroup}}
}{
\renewrobustcmd*\mdf@footnoteoutput{%
\ifvoid\@mdf@footins\else
\nobreak
\vskip\mdf@footenotedistance@length
\normalcolor
\mdf@footnoterule
\unvbox\@mdf@footins
\fi
}
\renewrobustcmd*\mdf@footnoteinput{%
\def\@mpfn{mdf@footnote}%
\def\thempfn{\themdf@footnote}%
\c@mdf@footnote\z@
\let\@footnotetext\@mdf@footnotetext
}
}
\long\def\@mdf@footnotetext#1{%
\global\setbox\@mdf@footins\vbox{%
\unvbox\@mdf@footins
\reset@font\footnotesize
\hsize\columnwidth
\@parboxrestore
\protected@edef\@currentlabel
{\csname p@mdf@footnote\endcsname\@thefnmark}%
\color@begingroup
\@makefntext{%
\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
\color@endgroup}}
\makeatother
\begin{document}
\lipsum[1]
\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule}
text in minipage\footnote{RTL footnote in minipage}\LTRfootnote{LTR footnote in minipage}
\end{minipage}}
\begin{mdframed}[linecolor=cyan]
text in mdframed\footnote{RTL footnote 1 in mdframed}\LTRfootnote{LTR footnote 1 in mdframed}
\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule-\parindent}
text in minipage, which is nested inside mdframed\footnote{RTL footnote in nested minipage}\LTRfootnote{LTR footnote in nested minipage}
\end{minipage}}
more text in mdframed\footnote{RTL footnote 2 in mdframed}\LTRfootnote{LTR footnote 2 in mdframed}
\end{mdframed}
normal text\footnote{RTL footnote}\LTRfootnote{LTR footnote}
\lipsum[2]
\end{document}