@David Purton
評論於如何在不明智的情況下自動強制乳膠不調整文字?
在 TeX 中按主題 (eijkhout.net/texbytopic/texbytopic.html)有一個例子,如果段落中的行太少,則將它們弄亂。請參閱第 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}
並且仍然獲得智能乳膠文本對齊的好處,為那些不喜歡對齊文本的行提供?
更新
後@芭芭拉-比頓評論,我認為可以使用\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\}
然而乳膠似乎不接受它,因為它拋出錯誤:
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={}
in,\vbox
因為 in 的第一個字母\vbox
開始下一段,因此\everypar
將處理下一個。它打開一個新的\vbox
並\everypar
處理新的,等等......永無止境的循環就在這裡。這會導致“TeX 容量”錯誤。
也許,你需要這樣的東西:
\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
in從主垂直清單中\setbox0=\lastbox \par
刪除\everypar
空白行(\lastbox
消耗縮排框並\par
完成空白段落:沒有任何內容加入主垂直清單)。下一個材料\everypar
打開\vbox
並在本地重新定義\par
以處理您的\eatlines
並且\everypar={}
由於上述原因在本地設定。