`\everypar` 正当化ステートメントはどのように使用できますか?

`\everypar` 正当化ステートメントはどのように使用できますか?

@David Purtonコメントした適切でない場合に、LaTeX でテキストを両端揃えしないように自動的に強制するにはどうすればよいでしょうか?

TeXトピック別(texbytopic の翻訳) 段落内の行が短すぎる場合に、行を不揃いにする例があります。セクション 5.9.6 を参照してください。おそらくこの方法が適しているでしょうか?

その本で次のページを見つけました:

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

これはマクロを参照します:

\newbox\linebox \newbox\snapbox
\def\eatlines{
\setbox\linebox\lastbox % check the last line
\ifvoid\linebox
\else % if it’s not empty
\unskip\unpenalty % take whatever is
{\eatlines} % above it;
% collapse the line
\setbox\snapbox\hbox{\unhcopy\linebox}
% depending on the difference
\ifdim\wd\snapbox<.90\wd\linebox
\box\snapbox % take the one or the other,
\else \box\linebox \fi
\fi}

その中に、テキストで埋められている行と、テキストの位置合わせによる空白.98を示す数字があることに気づくでしょう。98%2%LaTeX

現時点では以下のように使用できました:

% proposal.tex
% Based on http://www.latextemplates.com/template/simple-sectioned-essay
\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[brazil]{babel}

\usepackage{hyphsubst}
\usepackage{mathptmx}

\newbox\linebox \newbox\snapbox
\def\eatlines{
\setbox\linebox\lastbox % check the last line
\ifvoid\linebox
\else % if it’s not empty
\unskip\unpenalty % take whatever is
{\eatlines} % above it;
% collapse the line
\setbox\snapbox\hbox{\unhcopy\linebox}
% depending on the difference
\ifdim\wd\snapbox<.90\wd\linebox
\box\snapbox % take the one or the other,
\else \box\linebox \fi
\fi}

\begin{document}

\section{Riscos}

\indent
\vbox{

    In typesetting advertisement copy, a way of justifying paragraphs has
    become popular in recent years that is somewhere between flushright
    and raggedright setting. Lines that would stretch beyond certain limits
    are set with their glue at natural width. This single paragraph is but an
    example of this procedure; the macros are given next.

\par\eatlines}

\end{document}

さらに、テキストでは、 について言及していますit can be inserted automatically with \everypar。しかし、 でそれをどのように自動的に実行できるのかはわかりません\everypar。これまでに、これを試しました。

\begin{document}

\section{Riscos}

\indent
\everypar{

    In typesetting advertisement copy, a way of justifying paragraphs has
    become popular in recent years that is somewhere between flushright
    and raggedright setting. Lines that would stretch beyond certain limits
    are set with their glue at natural width. This single paragraph is but an
    example of this procedure; the macros are given next.

}

\end{document}

しかし、画像が空のまま表示されます。この\everypar文はどのように使用すればよいでしょうか?

それに続いて、各段落を何かに包み込むのではなく、このテキスト配置変換をすべてのテキストに適用する信頼性の高い/簡単な方法はありますか\everypar{ My paragraph 1 text } \n\n \everypar{ My paragraph 2 text }?


たとえば、次のように書く代わりに、

\begin{document}

\section{Riscos}

\indent
\everypar{

    My paragraph 1, In typesetting advertisement copy, a way of justifying paragraphs has
    become popular in recent years that is somewhere between flushright
}

\medskip
\indent
\everypar{

    My paragraph 2, and raggedright setting. Lines that would stretch beyond certain limits
    are set with their glue at natural width. This single paragraph is but an
    example of this procedure; the macros are given next.
}

\end{document}

次のようにもっと直接的なことを行ってください。

\begin{document}

\section{Riscos}

My paragraph 1, In typesetting advertisement copy, a way of justifying paragraphs has
become popular in recent years that is somewhere between flushright

\medskip
My paragraph 2, and raggedright setting. Lines that would stretch beyond certain limits
are set with their glue at natural width. This single paragraph is but an
example of this procedure; the macros are given next.

\end{document}

テキストの両端揃えが適切でない行に提供される、スマートな LaTeX テキスト両端揃えのメリットをまだ享受できますか?


アップデート

@バーバラビートン\everyparコメントでは、 andステートメントを使用して自動的に実行できると思います\par。次に、次のように記述してみました。

\begin{document}

\section{Riscos}

\everypar={\indent\vbox\{}
\par={\par\eatlines\}}

% \indent
% \vbox{

    In typesetting advertisement copy, a way of justifying paragraphs has
    become popular in recent years that is somewhere between flushright
    and raggedright setting. Lines that would stretch beyond certain limits
    are set with their glue at natural width. This single paragraph is but an
    example of this procedure; the macros are given next.

% \par\eatlines}

\end{document}

ステートメント\vbox{\par\eatlines\}各段落の開始/終了に挿入することを期待しています。ただし、LaTeX はこれを受け入れていないようで、次のエラーが発生します。

main2.tex:38: TeX capacity exceeded, sorry [input stack size=5000]. [    I]

main2.tex:33: Missing { inserted. [\par=]
main2.tex:33: Missing { inserted. [\par=]
main2.tex:33: Missing { inserted. [\par=]
main2.tex:33: Missing { inserted. [\par=]
main2.tex:33: Missing { inserted. [\par=]
...
Too many errors. TeX stopped.

答え1

の最初の文字が次の段落を開始するため、次の段落が処理されるため、ローカル\everypar={}に設定する必要があります。新しい段落が開き、新しい段落が処理されるなど... 終わりのないループがここにあります。これにより、「TeX 容量」エラーが発生します。\vbox\vbox\everypar\vbox\everypar

おそらく、次のようなものが必要です:

\newbox\linebox \newbox\snapbox
\def\eatlines{
  \setbox\linebox\lastbox % check the last line
  \ifvoid\linebox
  \else % if it’s not empty
    \unskip\unpenalty % take whatever is
    {\eatlines} % above it;
    \setbox\snapbox\hbox{\unhcopy\linebox}
    \ifdim\wd\snapbox<.98\wd\linebox
       \box\snapbox % take the one or the other,
    \else \box\linebox \fi
  \fi}

\everypar={\setbox0=\lastbox \par 
   \vbox\bgroup \everypar={}\def\par{\endgraf\eatlines\egroup}}


    In typesetting advertisement copy, a way of justifying paragraphs has
    become popular in recent years that is somewhere between flushright
    and raggedright setting. Lines that would stretch beyond certain limits
    are set with their glue at natural width. This single paragraph is but an
    example of this procedure; the macros are given next.

    Second paragraph.

\bye

\setbox0=\lastbox \parの は、\everyparメインの垂直リストから空の行を削除します (\lastboxはインデント ボックスを消費し、\par空の段落を確定します。メインの垂直リストには何も追加されません)。 の次のマテリアルが\everypar開き\vbox\par処理のためにローカルで再定義されます。 \eatlinesAnd は\everypar={}、上記の理由により、ここでローカルに設定されます。

関連情報