我怎样才能通过自动连字等方式对齐此类文本?(这不会影响文本的其余部分?如果我使用 \linebreak,它将转到下一行,但不会对齐前面的文本。
我希望每行都延伸到整个宽度。我不介意连字,只要它是特定的并且不会影响我不想使用连字的文档的其余部分。
编辑:
% !TEX TS-program = pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\usepackage{titlesec}
\usepackage{lipsum} %example text
%justify without hyphen
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\frenchspacing
%include additional layer called paragraph
\titleformat{\paragraph}{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\begin{document}
\paragraph*{((2R,3R,4S,5R,6R)-3,4,5-tris(benzyloxy)-6-(((2R,3R,4S,5R,6R)-3,4,5-tris(benzyloxy)-6-((benzyloxy)methyl)tetrahydro-2H-pyran-2-yl)oxy)tetrahydro-2H-pyran-2-yl)methanol ((OBn)$ _7$-6-TreOH)}
\lipsum[1]
\end{document}
答案1
您可以在每个字母后插入一个断点(用于\
节省空间并{...}
保护数学或其他结构。
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\usepackage{titlesec}
\usepackage{lipsum} %example text
%justify without hyphen
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\frenchspacing
%include additional layer called paragraph
\titleformat{\paragraph}{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\def\zz#1{\zzz#1{}}
\def\zzz#1{\def\tmp{#1}\ifx\tmp\empty\else#1\linebreak[0]\expandafter\zzz\fi}
\begin{document}
\paragraph*{\zz{((2R,3R,4S,5R,6R)-3,4,5-tris(benzyloxy)-6-(((2R,3R,4S,5R,6R)-3,4,5-tris(benzyloxy)-6-((benzyloxy)methyl)tetrahydro-2H-pyran-2-yl)oxy)tetrahydro-2H-pyran-2-yl)methanol\ ((OBn){$_7$}-6-TreOH)}}
\lipsum[1]
\end{document}