我正在尝试在环境中包装图片。我看到那里的人们insbox.tex
在不同的答案中推荐使用。下面的代码一切都很好。但是,当图片被引入后,\begin{group}
它根本不起作用。
编辑:我不\leavevmode
这么认为。
看看我的 MWE:
\documentclass{book}
\usepackage{amsthm}
\usepackage{lipsum}
\newtheorem{thm}{Theorem}
\usepackage{graphicx}
\usepackage[font=footnotesize]{caption}
\input{insbox.tex}
\usepackage{threeparttable}
\usepackage{xargs}
\newcommand\insertpictureR[3][5]{
\InsertBoxR{0}{\begin{threeparttable}\begin{tabular}{c@{}}\includegraphics[width=#3\textwidth]{#2}\end{tabular}\captionof{figure}{}\end{threeparttable}}[#1]%
}
\newcommand\insertpictureL[3][5]{
\InsertBoxL{0}{\begin{threeparttable}\begin{tabular}{c@{}}\includegraphics[width=#3\textwidth]{#2}\end{tabular}\captionof{figure}{}\end{threeparttable}}[#1]%
}
\begin{document}
\begin{thm}
\insertpictureR{example-image-a}{0.2}
\lipsum[1]
\end{thm}
\begin{proof}
\insertpictureL{example-image-a}{0.2}
\lipsum[1]
\end{proof}
\end{document}
答案1
您缺少了\leavevmode
和一些其他好东西。请注意,您的宏似乎系统地要求使用可选参数(也许没有正确考虑标题高度?)。
\documentclass{book}
\usepackage{amsthm}
\usepackage{lipsum}
\newtheorem{thm}{Theorem}
\usepackage{graphicx}
\usepackage[font=footnotesize]{caption}
\input{insbox.tex}
\usepackage{threeparttable}
\usepackage{xargs}
\newcommand\insertpictureR[3][5]{
\InsertBoxR{0}{\begin{threeparttable}\begin{tabular}{c@{}}\includegraphics[width=#3\textwidth]{#2}\end{tabular}\captionof{figure}{}\end{threeparttable}}[#1]%
}
\newcommand\insertpictureL[3][5]{
\InsertBoxL{0}{\begin{threeparttable}\begin{tabular}{c@{}}\includegraphics[width=#3\textwidth]{#2}\end{tabular}\captionof{figure}{}\end{threeparttable}}[#1]%
}
\begin{document}
\begin{thm} \leavevmode
\insertpictureR[3]{example-image-a}{0.2}\noindent
\lipsum[1]
\end{thm}%
\begin{proof}
\leavevmode\insertpictureL[3]{example-image-a}{0.2}\noindent
\lipsum[1]
\end{proof}
\end{document}