具有水平縮排的自訂環境

具有水平縮排的自訂環境

我正在嘗試創建一個由兩部分組成的簡單環境:

  1. 粗體文字後面跟著右箭頭
  2. (多)行帶縮排的文本,位於粗體文本下方

到目前為止我所擁有的:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{subfig}

\newenvironment{myeventeq}[1]
  {\textbf{#1} $\Rightarrow$\vspace{1ex}\par
   \hspace*{2em}%%
   \begin{minipage}{\dimexpr\columnwidth-2em}}
  {\end{minipage}}

\begin{document}

\begin{figure}    
  \subfloat[piece1]{  
    \begin{myeventeq}{piece of bold text}
      condition 1 to be satisfied\\
      condition 2 to be satisfied
    \end{myeventeq}
  }
  \subfloat[piece2]{
    \begin{myeventeq}{piece of bold text}
      condition 1 to be satisfied\\
      condition 2 to be satisfied
    \end{myeventeq}  
  }
  \caption{dual caption}
\end{figure}

\end{document}

這會產生以下結果:

例子

目前的問題是:

  • 條件應位於粗體文字下方
  • 第二個子圖落在頁面上。

答案1

如果您想避免list環境,您可以為您的結構圍繞minipage.這樣做的問題是它不會跨頁。但既然你提到了,subfig我假設這個環境不是為了跨越多個頁面。

\documentclass{article}
\usepackage{amsmath,amssymb}

\newenvironment{myeventeq}[1]
  {\textbf{#1} $\Rightarrow$\vspace{1ex}\par
   \hspace*{2em}%%
   \begin{minipage}{\dimexpr\columnwidth-2em}}
  {\end{minipage}}

\begin{document}

Hello

\begin{myeventeq}{piece of bold text}
  condition 1 to be satisfied\\
  condition 2 to be satisfied
\end{myeventeq}

\end{document}

相關內容