複数列: 左揃えにして、未使用のスペースを左から埋めます。(奇数ページ)

複数列: 左揃えにして、未使用のスペースを左から埋めます。(奇数ページ)

尊敬するコミュニティの皆様、私は2列の文書レイアウトを使用しており、通常は

  1. テキストを左揃えにすると、右側の未使用スペースが埋められ、
  2. テキストを右揃えにして、右側の未使用スペースを埋めます。

テキストを左揃えにし、最長の行に応じてテキスト ボックス全体を列のできるだけ右側に配置して、未使用のスペースを左側から埋める配置にするにはどうすればよいでしょうか。

この解決策は奇数ページの列全体に影響するはずです (中央で定義できる必要があります)。また、テキストの幅は事前にわかりません。列ごとに異なる可能性があります。

ご意見ありがとうございます。

奇数ページでの報い行為

答え1

画像をクリックすると、より高解像度で表示されます

編集1: 奇数/偶数ページチェックを追加

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\usepackage{array}
\usepackage{varwidth}
\usepackage{changepage}
\strictpagecheck
\def\maxwidth{13cm}
\newcolumntype{M}{>{\begin{varwidth}{\maxwidth}}l<{\end{varwidth}}}
\newenvironment{myenvi}
    {%
        \checkoddpage
        \ifoddpage
            \hfill\begin{tabular}{@{}M@{}}
        \fi
    }
    {%
        \checkoddpage
        \ifoddpage
            \end{tabular}\hspace{-3.5pt}
        \fi
    }

\setlength{\parskip}{1ex}
\begin{document}
\lipsum[1]

\begin{myenvi}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
\end{myenvi}

And some more normal lines

\begin{myenvi}
This is a short text for testing whose total width is clearly less than 10cm.

And this is an even shorter text.
\end{myenvi}

\lipsum[2-6]

\begin{myenvi}
This is the environment for check in an even page. It should be like normal text.

Yes, this is normal text!
\end{myenvi}

\lipsum[7]
\end{document}

ページ 1 (奇数):

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

ページ2(偶数):

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

元の回答

新しいtabular列タイプを定義して使用する\hfill

\documentclass{article}
\usepackage{lipsum}
\usepackage{array}
\usepackage{varwidth}
\newcolumntype{M}{>{\begin{varwidth}{10cm}}l<{\end{varwidth}}}

\setlength{\parskip}{1ex}
\begin{document}
\lipsum[1]

\hfill\begin{tabular}{@{}M@{}}
Oh, this is what I want!

I really want some lines like this

And this line is a bit too long, so it will be broken to some lines blah blah. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines. And this line is a bit too long, so it will be broken to some lines.
\end{tabular}

\lipsum[2]
\end{document}

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

関連情報