¿Cómo podría usarse la declaración de justificación `\everypar`?

¿Cómo podría usarse la declaración de justificación `\everypar`?

@David Purtoncomentado en¿Cómo forzar automáticamente al látex a no justificar el texto cuando no es prudente?

En TeX por tema (eijkhout.net/texbytopic/texbytopic.html) hay un ejemplo de cómo hacer que las líneas de un párrafo queden irregulares si son demasiado insuficientes. Ver sección 5.9.6. ¿Quizás este método sería adecuado?

En ese libro encontré la página:

ingrese la descripción de la imagen aquí

Se refiere a la macro:

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

Dentro de él podemos notar el .98número, que debe hacer referencia 98%a la línea que se está llenando con texto y 2%como espacio vacío debido a la LaTeXjustificación del texto.

Actualmente pude usarlo como:

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

Además en el texto, menciona aproximadamente it can be inserted automatically with \everypar. Sin embargo, no entiendo cómo se podría hacer automáticamente con \everypar. Hasta ahora probé esto:

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

Sin embargo, la imagen sale vacía. ¿Cómo podría \everyparusarse la declaración?

A continuación, ¿existe una manera confiable/simple de aplicar esta transformación de justificación de texto a todo el texto, en lugar de incluir cada párrafo en algo como \everypar{ My paragraph 1 text } \n\n \everypar{ My paragraph 2 text }?


Por ejemplo, en lugar de escribir:

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

Simplemente haga algo más sencillo como:

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

¿Y seguir disfrutando de los beneficios de la justificación inteligente de texto en látex, que se ofrece para líneas en las que justificar el texto no sería agradable?


Actualizar

Después@barbara-beetoncomentario, creo que se puede hacer automáticamente usando las declaraciones \everypary \par. Luego intenté escribir:

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

Espero que las declaraciones \vbox{y \par\eatlines\}que se inserten en cada principio/final de párrafo. Sin embargo, el látex parece no aceptarlo, ya que arroja el error:

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.

Respuesta1

Debe configurarlo localmente \everypar={}porque \vboxla primera letra \vboxcomienza con el siguiente párrafo, por lo que \everyparse procesa el siguiente. Se abre un nuevo \vboxy \everyparse procesa lo nuevo, etc. Aquí hay un bucle sin fin. Esto genera un error de "capacidad TeX".

Quizás necesites algo como esto:

\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

El \setbox0=\lastbox \parin \everyparelimina la línea vacía de la lista vertical principal ( \lastboxconsume el cuadro de sangría y \parfinaliza el párrafo vacío: no se agrega nada a la lista vertical principal). El siguiente material se \everyparabre \vboxy se redefine localmente \parpara procesar su \eatlinesY \everypar={}se establece aquí localmente debido al motivo explicado anteriormente.

información relacionada