我发现了一个(我认为又好又简单)添加垂直条的方法除了数学演示之外。我希望能够在此环境中放置一个图形,但我收到错误:./test.tex:21: LaTeX Error: Not in outer par mode.
这是我的 MWE:
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage[framemethod=TikZ]{mdframed}
\surroundwithmdframed[
topline=false,
rightline=false,
bottomline=false,
leftmargin=\parindent,
skipabove=\medskipamount,
skipbelow=\medskipamount
]{proof}
\begin{document}
\noindent
Preceding Text
\begin{proof}[Proof by Paradox]
my proof, I really wish a figure could be here\dots
\end{proof}
\dots but I can only compile if it is here:
\begin{figure}[!ht]
\centering
...
\caption{fig.1}
\end{figure}
\end{document}
enviro
我应该补充一点,当尝试使用该包将图形放置在用户定义的环境中时,也会出现同样的错误。
有没有办法在这样的环境中放置一个图形?
答案1
评论暗示了图形环境和用户定义环境之间的不兼容,以下是其工作原理:
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{tikz}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage[framemethod=TikZ]{mdframed}
\usetikzlibrary{arrows}
\usetikzlibrary{patterns}
\usetikzlibrary{backgrounds}
\surroundwithmdframed[
topline=false,
rightline=false,
bottomline=false,
leftmargin=\parindent,
skipabove=\medskipamount,
skipbelow=\medskipamount
]{proof}
\begin{document}
\noindent
Preceding Text
\begin{proof}[Proof]
my proof, the related figure and\dots
\begin{tikzpicture}[framed,background rectangle/.style={ultra thick,draw=none, top color=white, bottom color=white, rounded corners},scale=0.65]
\begin{scope}[x={(.7cm,.3cm)},z={(.8cm,-.4cm)}]
%
% poutre
\path (1,0,0);
\pgfgetlastxy{\cylxx}{\cylxy}
\path (0,1,0);
\pgfgetlastxy{\cylyx}{\cylyy}
\path (0,0,1);
\pgfgetlastxy{\cylzx}{\cylzy}
\pgfmathsetmacro{\cylt}{(\cylzy * \cylyx - \cylzx * \cylyy)/ (\cylzy * \cylxx - \cylzx * \cylxy)}
\pgfmathsetmacro{\ang}{atan(\cylt)}
\pgfmathsetmacro{\ct}{1/sqrt(1 + (\cylt)^2)}
\pgfmathsetmacro{\st}{\cylt * \ct}
\fill[black!20] (\ct,\st,0) -- ++(0,0,-4) arc[start angle=\ang,delta angle=180,radius=1] -- ++(0,0,4) arc[start angle=\ang+180,delta angle=-180,radius=1];
\begin{scope}[every path/.style={thick}]
\draw[] (0,0,0) circle[radius=1];
\draw[] (\ct,\st,-4) arc[start angle=\ang,delta angle=180,radius=1];
\draw[] (\ct,\st,-4) -- ++(0,0,4);
\draw (-\ct,-\st,-4) -- ++(0,0,4);
%
%
\draw[black!25,dashed] (\ct,\st,-8) arc[start angle=\ang,delta angle=180,radius=1];
\draw[black!25,dashed] (\ct,\st,-8) arc[start angle=\ang,delta angle=-180,radius=1];
\end{scope}
\end{scope}
\end{tikzpicture}
\captionof{figure}{\dots its caption}
\end{proof}
\end{document}