@David Purton commented at How to automatically force latex to not justify the text when it is not wise?
In TeX by Topic (eijkhout.net/texbytopic/texbytopic.html) there is an example of getting lines in a paragraph to be raggedright if they are too underful. See section 5.9.6. Perhaps this method would be suitable?
On that book I found the page:
It does refer to the 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}
Within it we may notice the .98 number, which should refer to 98% of the line being filled with text and 2% as empty spacing due the LaTeX text justification.
Currently I was able to use it as:
% 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}
Moreover on the text, he does mention about it can be inserted automatically with \everypar. Though, I do not understand how it could be done automatically with \everypar. So far I tried this:
\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}
However the image is coming out empty. How could the \everypar statement be used?
Following it, is there a reliable/simple way to apply this text justification transformation to all text, instead of englobing each paragraph on something as \everypar{ My paragraph 1 text } \n\n \everypar{ My paragraph 2 text }?
For example, instead of writing:
\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}
Just do something more straight forward as:
\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}
And still get the benefits of the smart latex text justification, offered for lines where justifying the text would not be pleasant?
Update
After @barbara-beeton comment, I think it can be done automatically using the \everypar and \par statements. Then I tried to write:
\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}
In hope to the statements \vbox{ and \par\eatlines\} to be inserted every paragraph start/end. However latex seems not to be accepting it, as it is throwing the 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.

\everyparis an assignment of what is to be done at the start of every paragraph. it is not the text of the paragraph. that is why your output is blank. however, since\everyparis used all over the place in latex, working around that is more complicated that i have time to tackle at the moment. – barbara beeton Apr 21 '17 at 14:40\everyparand\parto insert automatically the statements required by the macro on every text paragraphs. Though after I tried so, it does not compiles the latex. I updated the answer within it. – user Apr 21 '17 at 15:21\vbox\{will not create a box; an "unadorned" brace is needed for that, and\{will typeset a brace. use\bgroupand\egroupinstead. (they are equivalent to the opening and closing braces.) but i'd still be very wary of messing up the existing settings of\everyparthat are rife in latex. – barbara beeton Apr 21 '17 at 15:47\everypar={\vbox\bgroup}and\par={\eatlines\egroup}? However now it is throwing the errormain2.tex:33: TeX capacity exceeded, sorry [semantic nest size=500]. [\par=]. – user Apr 21 '17 at 16:17