如何将具有 1 个参数的默认命令转换为环境?

如何将具有 1 个参数的默认命令转换为环境?

我正在使用cutwin包:

\documentclass[12pt,a4paper,twoside]{article}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage[left=3cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usepackage{color}
\usepackage{cutwin}
\usepackage{caption}
\begin{document}

\opencutright
\begin{proof}
\renewcommand{\windowpagestuff}{\centering\definecolor{zzttqq}{rgb}{0.6,0.2,0.}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-2.82980083729075,-0.4587409579476702) rectangle (4.959293631076773,4.559442339280329);
\fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (0.,4.079442197806347) -- (-2.3716188097397195,0.) -- (4.588384370678319,0.) -- cycle;
\draw [color=zzttqq] (0.,4.079442197806347)-- (-2.3716188097397195,0.);
\draw [color=zzttqq] (-2.3716188097397195,0.)-- (4.588384370678319,0.);
\draw [color=zzttqq] (4.588384370678319,0.)-- (0.,4.079442197806347);
\begin{scriptsize}
\draw [fill=black] (0.,4.079442197806347) circle (1.0pt);
\draw[color=black] (0.15929143768502174,4.352169550916564) node {$A$};
\draw [fill=black] (-2.3716188097397195,0.) circle (1.0pt);
\draw[color=black] (-2.218891467222709,0.2721683483877123) node {$B$};
\draw [fill=black] (4.588384370678319,0.) circle (1.0pt);
\draw[color=black] (4.7411117131953295,0.2721683483877123) node {$C$};
\end{scriptsize}
\end{tikzpicture}
\captionsetup{type=figure}
\caption{}}

\begin{cutout}{0}{.5\linewidth}{1pt}{12}
\lipsum[1]
\end{cutout}
\end{proof}

\end{document}

这是一个很棒的软件包,但我想通过以下命令进行更新

\renewcommand{\windowpagestuff}{\centering
\begin{tikzpicture}
<some tikz-code>
\end{tikzpicture}}

newtikzpicture如下环境:

\begin{proof}
 \begin{newtikzpicture}
<some tikz-code>
\end{newtikzpicture}

\begin{cutout}{0}{.5\linewidth}{1pt}{12}
\lipsum[1]
\end{cutout}
\end{proof}

我该怎么做?谢谢你的帮助!

答案1

像这样?

\documentclass[12pt,a4paper,twoside]{article}
\usepackage{lipsum}
\usepackage{amsthm}
\usepackage[left=3cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{cutwin}
\usepackage{caption}

\usepackage{environ}
\NewEnviron{cutoutright}{\global\let\windowpagestuff\BODY}

\begin{document}

\opencutright
\begin{proof}
  \begin{cutoutright}%
    \centering
    \definecolor{zzttqq}{rgb}{0.6,0.2,0.}
    \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
      \clip(-2.82980083729075,-0.4587409579476702) rectangle (4.959293631076773,4.559442339280329);
      \fill[color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (0.,4.079442197806347) -- (-2.3716188097397195,0.) -- (4.588384370678319,0.) -- cycle;
      \draw [color=zzttqq] (0.,4.079442197806347)-- (-2.3716188097397195,0.);
      \draw [color=zzttqq] (-2.3716188097397195,0.)-- (4.588384370678319,0.);
      \draw [color=zzttqq] (4.588384370678319,0.)-- (0.,4.079442197806347);
      \begin{scriptsize}
        \draw [fill=black] (0.,4.079442197806347) circle (1.0pt);
        \draw[color=black] (0.15929143768502174,4.352169550916564) node {$A$};
        \draw [fill=black] (-2.3716188097397195,0.) circle (1.0pt);
        \draw[color=black] (-2.218891467222709,0.2721683483877123) node {$B$};
        \draw [fill=black] (4.588384370678319,0.) circle (1.0pt);
        \draw[color=black] (4.7411117131953295,0.2721683483877123) node {$C$};
      \end{scriptsize}
    \end{tikzpicture}
    \captionsetup{type=figure}
    \caption{}
  \end{cutoutright}
  \begin{cutout}{0}{.5\linewidth}{1pt}{12}
    \lipsum[1]
  \end{cutout}
\end{proof}

\end{document}

在此处输入图片描述

相关内容