特別な「または」環境を作成するにはどうすればよいでしょうか?

特別な「または」環境を作成するにはどうすればよいでしょうか?

左側に縦線があり、改行ごとに自動的に「または」が挿入される環境を作成したいと思います。その目的は数学のコンテキストです。

次のようになります:

モデル

答え1

このtcolorboxパッケージを使用すると、垂直線を作成する環境を作成できます。

\documentclass[a4paper]{article}
\usepackage[most]{tcolorbox}
% \usepackage{pgfplots}


\newtcolorbox{env}{
        enhanced,
        breakable, % This make the box breakable
        boxrule=0pt,
        frame hidden,
        borderline west={2pt}{0pt}{black}, % this create the line
        colback=white, % The background color,
        math upper,
        hbox,
        center
    }

\begin{document}
 Text text text
    \begin{env}
        \int_{-\infty}^{\infty}f(x)\delta(x-a)dx = f(a)
    \end{env}

\end{document}

ここに画像の説明を入力してください

答え2

配列のような環境を使用して、または最初ではないすべての要素の前。あまりきれいではありませんが、機能します。

    \documentclass[a4paper]{article}

    \usepackage{ifthen}
    \newcounter{orcounter}

    \newenvironment{orlist}{%
      \noindent\begin{tabular*}{\textwidth}{|l}
      \setcounter{orcounter}{0}
    }{%
     \end{tabular*}
    }

    \newcommand{\oritem}[1]{%
      \ifthenelse{\equal{\theorcounter}{0}}{\hspace{-1em}}{\\ \textbf{or}\\}
      #1\stepcounter{orcounter}
    }

    % -- Usage Example
    \begin{document}

    \begin{orlist}
      \oritem{example 1}
      \oritem{example 2}
    \end{orlist}

    \end{document}

答え3

私は自分で解決策を見つけました:

\documentclass[a4paper]{article}

\newenvironment{ouenv}
{\left\lvert\begin{array}{l}}
{\end{array}\right.}

\begin{document}
\[\begin{ouenv}G\text{ abélien} \\ \text{ou} \\ I=\ensvide\end{ouenv}\]
\end{document}

次の結果が得られます。

結果

(テキストはフランス語ですが問題ありません)

答え4

クラスメートの助けを借りて、私が当初望んでいたものにさらに近い新しいソリューションを作成することができました。環境の代わりにコマンドを使用しますが、はるかに優れています。

コードは次のとおりです:

\newcounter{orcounter}

\newenvironment{orlist}
{
\begin{array}{|l}
\setcounter{orcounter}{0}
}
{
\end{array}
}

\newcommand{\oritem}[1]{%
\ifthenelse{\theorcounter<1}{}{\\ \text{ou} \\}#1\stepcounter{orcounter}
}

\NewDocumentCommand{\orenv}{>{\SplitList{\\}}m}{%
\begin{orlist}\ProcessList{#1}{\oritem}\end{orlist}}

次のように非常に簡単に使用できます。

\[\orenv{G\text{ abélien} \\ I=\ensvide}\]

関連情報