複数行の数式表示行の残りの長さを決定する

複数行の数式表示行の残りの長さを決定する
\documentclass{article}
\pagestyle{empty}
\usepackage{mathtools}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\[
  \text{beginning}\land
  \begin{multlined}[t][\linewidth]
   (\text{extremely long and boring junk occupying lots of space})\\\relax
   [\text{a variable substitution in brackets}]
 \end{multlined}
\]
\lipsum[2]
\end{document}

収穫

出力

2 番目の数式行 (括弧内の置換) が右のテキスト余白を超えるのではなく、右揃えになるようにする議論の代わりに何を言うべきでしょう\linewidthか。つまり、「右余白までの行の残りの長さ」をどのように計算するのでしょうか。

(ご想像のとおり、これは実際の大きな例を過度に単純化したバージョンです。そのため、この MWE では、multline*代わりに を使用することはお勧めしません。これは、私の大きな例では、これが別のブロック数学環境内にネストされているためです。)

答え1

パッケージを使用することもできますlinegoal(バグがないわけではありませんが、単一のアプリケーションであれば問題ないはずです)。

\documentclass{article}
\pagestyle{empty}
\usepackage{mathtools}
\usepackage{linegoal}
\usepackage{lipsum}

\begin{document}
\lipsum[1][1-3]
\[
  \text{beginning}\land
  \begin{multlined}[t][\linegoal]
   (\text{extremely long and boring junk occupying lots of space})\\\relax
   [\text{a variable substitution in brackets}]
 \end{multlined}
\]
\lipsum[2][1-3]
\[
  \text{beginning}\land
  \begin{multlined}[t][0.95\linegoal]
   (\text{extremely long and boring junk occupying lots of space})\\\relax
   [\text{a variable substitution in brackets}]
 \end{multlined}
\]
\lipsum[3][1-3]

\end{document}

\land2 番目のケースでは、周囲のスペースが圧縮されるのを防ぎ、中央揃えが見える (ただし、スペースを無駄にしすぎない)ように、必要な幅を縮小しました。

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

答え2

環境は行の中央に配置するのでmultilined、右余白と重ならないように、\linewidthその前に追加する部分よりも短くする必要があります。

mathtoolsパッケージをロードするので、任意のテキストの幅を取得するcalcマクロを利用できます。これを使用すると、環境の前に追加したものを幅から減算できます(欠点は、この内容を 2 回入力する必要があることです。そのため、これがセットアップで実行可能かどうかはわかりません)。\widthof\linewidthmultilined

\documentclass{article}
\pagestyle{empty}
\usepackage{mathtools}
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\[
  \text{beginning} \land
  \begin{multlined}[t][\linewidth-\widthof{$\text{beginning} \land$}]
   (\text{extremely long and boring junk occupying lots of space}) \\
   [\text{a variable substitution in brackets}]
 \end{multlined}
\]
\lipsum[2]
\end{document}

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

関連情報