如何防止命令中出现换行

如何防止命令中出现换行

我正在使用包biocon,它允许在文档开头定义物种名称,可以通过编写例如 \plant{At} 来使用,它将被翻译成“A. thaliana”。但是,“A.”和“thaliana”之间允许换行。我该如何避免这种情况?我试图更新命令,但这会产生错误(我的代码行是未注释的行)。如何正确解决这个问题?

\documentclass{article}
\usepackage{biocon}
%\renewcommand{\plant}{\mbox{\plant}}
\begin{document}
\newplant{At}{genus=Arabidopsis,epithet=thaliana,author=Heynh.,oldauthor=L.}


\plant{At}
Many plants are very beautiful. However, there are \plant{At} is such a plant, only having white flowers.

\end{document}

答案1

这是修改后的样式,\nolinebreak在缩写形式中在句号后添加。我还添加了“原始”测试,以查看我们重新定义的设置是否有效。

\documentclass{article}
\usepackage{biocon}

\newtaxastyle{a+}
  {\taxit{\taxonfirst{!genus!.\nolinebreak}\taxon{ !epithet!}}}
\defaultabbr{a+}

\newplant{At}{genus=Arabidopsis,epithet=thaliana,author=Heynh.,oldauthor=L.}

\begin{document}


\plant{At}
Many plants are very beautiful. However, there are \plant{At} is such a plant, only having white flowers.


\bigskip

A test with the default setting to see that our replacement works

\newplant{Atx}{genus=Arabidopsis,epithet=thaliana,author=Heynh.,oldauthor=L.} % the same as before
\defaultabbr{a}% this is the default

\plant{Atx}
Many plants are very beautiful. However, there are \plant{Atx} is such a plant, only having white flowers.

\end{document}

在此处输入图片描述

答案2

您可以重新定义用于缩写的 a 样式并添加~

\documentclass{article}
\usepackage{biocon}

\newtaxastyle{a}
  {\taxit{\taxonfirst{!genus!.}\taxon{~!epithet!}}}

\begin{document}
\newplant{At}{genus=Arabidopsis,epithet=thaliana,author=Heynh.,oldauthor=L.}


\plant{At}
Many plants are very beautiful. However, there are \plant{At} is such a plant, only having white flowers.

\end{document}

相关内容