Wie könnte die Begründungsanweisung „\everypar“ verwendet werden?

Wie könnte die Begründungsanweisung „\everypar“ verwendet werden?

@David Purtonkommentiert beiWie kann man Latex automatisch dazu zwingen, den Text nicht im Blocksatz auszurichten, wenn dies nicht sinnvoll ist?

In TeX nach Thema (eijkhout.net/texbytopic/texbytopic.html) Es gibt ein Beispiel, wie man Zeilen in einem Absatz rechtsbündig formatieren kann, wenn sie zu kurz sind. Siehe Abschnitt 5.9.6. Vielleicht wäre diese Methode geeignet?

Zu diesem Buch habe ich die Seite gefunden:

Bildbeschreibung hier eingeben

Es bezieht sich auf das Makro:

\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}

Darin können wir die .98Zahl erkennen, die sich auf 98%die mit Text gefüllte Zeile und 2%auf den Leerraum aufgrund der LaTeXTextausrichtung beziehen soll.

Derzeit konnte ich es wie folgt verwenden:

% 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}

Außerdem erwähnt er im Text it can be inserted automatically with \everypar. Allerdings verstehe ich nicht, wie das automatisch mit gemacht werden könnte \everypar. Bisher habe ich Folgendes versucht:

\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}

Das Bild ist jedoch leer. Wie könnte die \everyparAussage verwendet werden?

Gibt es im Anschluss daran eine zuverlässige/einfache Möglichkeit, diese Textausrichtungstransformation auf den gesamten Text anzuwenden, anstatt jeden Absatz als Ganzes anzuordnen \everypar{ My paragraph 1 text } \n\n \everypar{ My paragraph 2 text }?


Anstatt beispielsweise zu schreiben:

\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}

Machen Sie einfach etwas Einfacheres wie:

\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}

Und dennoch die Vorteile der intelligenten Latex-Textausrichtung nutzen, die für Zeilen angeboten wird, bei denen die Textausrichtung unangenehm wäre?


Aktualisieren

Nach@barbara-beeton\everyparKommentar, ich denke, es kann automatisch mit den und Anweisungen gemacht werden \par. Dann habe ich versucht zu schreiben:

\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}

Ich hoffe, dass die Anweisungen am Anfang/Ende jedes Absatzes eingefügt \vbox{werden \par\eatlines\}. Latex scheint dies jedoch nicht zu akzeptieren, da es den folgenden Fehler ausgibt:

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.

Antwort1

Sie müssen lokal festlegen, \everypar={}dass in \vbox, da der erste Buchstabe in \vboxden nächsten Absatz startet, also \everyparwird „next“ verarbeitet. Es öffnet sich ein neuer \vboxund „new“ \everyparwird verarbeitet usw. … Es handelt sich hier um eine Endlosschleife. Dies führt zu einem „TeX-Kapazitäts“-Fehler.

Möglicherweise benötigen Sie so etwas:

\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

Das \setbox0=\lastbox \parin \everyparentfernt die leere Zeile aus der vertikalen Hauptliste ( \lastboxverbraucht das Einrückungsfeld und \parschließt den leeren Absatz ab: der vertikalen Hauptliste wird nichts hinzugefügt). Als nächstes wird Material in \everypargeöffnet \vboxund lokal neu definiert, \parum Ihr \eatlinesUnd zu verarbeiten, und \everypar={}wird aus dem oben erläuterten Grund hier lokal festgelegt.

verwandte Informationen