我有以下代码设置为主要字体,其中GFSArtemisia
仅包含两段文本,其中有一些空白处需要学生填写。我注意到,如果我使用除默认字体之外的某些字体作为主要字体,例如,,,LaTeX
以及GFSArtemisia
可能我没有检查过的其他字体,换行符将无法正常工作,如下图所示。除了手动将没有正确换行符的每行末尾放置外,如何修复?请注意:如果您注释下面代码的第 7 行:那么结果没有问题。这是 MWE:Comic Sans
Segoe Script
STIX Two Text
\linebreak
\setmainfont{GFSArtemisia}\setsansfont{FiraSans}\setmonofont{Consolas}
% !TeX program = lualatex
\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage{setspace}
\usepackage[no-math]{fontspec}
\defaultfontfeatures{Scale=MatchLowercase, Script=Greek}\defaultfontfeatures[\rmfamily]{Scale=1.1}
\setmainfont{GFSArtemisia}\setsansfont{FiraSans}\setmonofont{Consolas}
\newcommand\dotfillin[1][4cm]{\makebox[#1]{\dotfill}}
\begin{document}
\doublespacing
\noindent This is a text \dotfillin[5cm] containing some empty \dotfillin[5cm] spaces to be completed from \dotfillin[5cm] students, but if set main font to some other fonts like \dotfillin[5cm] STIX Two Tesxt, Comic Sans, Segoe Script, GFS Artemisia and others \dotfillin[5cm] the linebreaks \dotfillin[5cm] does not work properly \dotfillin[5cm]. How can be fixed \dotfillin[5cm]?
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing \dotfillin[5cm] elit, sed do eiusmod tempor incididunt ut labore et \dotfillin[5cm] dolore magna aliqua. Ut enim ad minim \dotfillin[5cm] veniam, quis nostrud \dotfillin[5cm] exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit \dotfillin[5cm] in voluptate velit esse cillum dolore eu \dotfillin[5cm] fugiat nulla pariatur. \dotfillin[5cm] excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia \dotfillin[5cm] deserunt mollit anim id est laborum.
\end{document}
答案1
\sloppy
在本例中,添加可解决所有溢出框的问题。
% !TeX program = lualatex
\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm,showframe]{geometry}
\usepackage{setspace}
\usepackage[no-math]{fontspec}
\defaultfontfeatures{Scale=MatchLowercase}\defaultfontfeatures[\rmfamily]{Scale=1.1}
\setmainfont{GFSArtemisia}\setsansfont{FiraSans}\setmonofont{Consolas}
\newcommand\dotfillin[1][4cm]{\makebox[#1]{\dotfill}}
\begin{document}
\sloppy % <<<<<<<<<<<<<<<<
\doublespacing
\noindent This is a text \dotfillin[5cm] containing some empty \dotfillin[5cm] spaces to be completed from \dotfillin[5cm] students, but if set main font to some other fonts like \dotfillin[5cm] STIX Two Tesxt, Comic Sans, Segoe Script, GFS Artemisia and others \dotfillin[5cm] the linebreaks \dotfillin[5cm] does not work properly \dotfillin[5cm]. How can be fixed \dotfillin[5cm]?
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing \dotfillin[5cm] elit, sed do eiusmod tempor incididunt ut labore et \dotfillin[5cm] dolore magna aliqua. Ut enim ad minim \dotfillin[5cm] veniam, quis nostrud \dotfillin[5cm] exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit \dotfillin[5cm] in voluptate velit esse cillum dolore eu \dotfillin[5cm] fugiat nulla pariatur. \dotfillin[5cm] excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia \dotfillin[5cm] deserunt mollit anim id est laborum.
\end{document}
产生类似的结果\setlength{\emergencystretch}{2em}