Определение конкретной среды в LaTeX

Определение конкретной среды в LaTeX

Мне нужна помощь в написании примера окружения. Я просто хочу, чтобы оно выглядело как на рисунке ниже, который я взял из старой книги, которая есть в моей библиотеке.

введите описание изображения здесь

Вот что я сделал.

    \newtheorem{exem}{EXAMPLE}

    \newenvironment{ex}{\parshape=3
    0\textwidth \textwidth
    0.25\textwidth 0.74\textwidth
    0pt \textwidth \begin{exem} \rm \hspace{0.2cm}}{\end{exem}}

    \begin{document}
        \begin{ex}
        Text
        \end{ex}
    \end{document} 

Однако этот код дает сбой, когда текст очень длинный в определенной среде. Затем у меня начинаются проблемы с правым полем. Я понятия не имею, как это решить. Пожалуйста, помогите мне определить эту среду?

решение1

Вот exampleсреда, которая задает выравнивание/форму абзаца с помощью \parshape:

введите описание изображения здесь

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\newcounter{example}
\newcommand{\examplename}{\textsc{Example}}
\makeatletter
\newenvironment{example}
  {\refstepcounter{example}% Step example counter
   \sbox\@tempboxa{\examplename~\theexample.~}% Store environment title
   % Set paragraph alignment
   \parshape 3 \wd\@tempboxa \dimexpr\linewidth-\wd\@tempboxa % Line 1
     \wd\@tempboxa \dimexpr\linewidth-\wd\@tempboxa % Line 2
     0pt \linewidth% Line 3+
    \noindent% No indent
    \leavevmode% Start paragraph
    \llap{\usebox\@tempboxa}% Insert environment title
    \ignorespaces}% Remove spaces
  {\par}
\begin{document}
\lipsum[1]
\begin{example}
  \lipsum[2]
\end{example}
\lipsum[3]
\begin{example}
  Some example content
\end{example}
\begin{example}
  Some more example content
\end{example}
\lipsum[4]
\end{document}

Связанный контент