在下面的代码中,我定义了两个命令\refpage
并\refpages
依次使用ulem
和soul
包,但是当句子超出行尾时,它们都不会中断句子。
\documentclass{book}
\usepackage{xcolor}
\usepackage{ulem}
\usepackage{soul}
\usepackage{fontspec}
\newcommand\refpage[1]{\textcolor[RGB]{18,93,153}{\bfseries\uline{#1}}}
\newcommand\refpages[1]{\textcolor[RGB]{18,93,153}{\bfseries\ul{#1}}}
\begin{document}
Maple provides an interactive problem-solving environment,
complete with procedures for performing symbolic,
numeric, and graphical computations. For more information
on the toolbar icons, refer to the \refpage{worksheet/reference/WorksheetToolbar}
help page. At the core of the Maple computer algebra system is a powerful
programming language. For more information on clearing the Maple internal
memory and command, refer to the restart help page.
Maple provides an interactive problem-solving environment,
complete with procedures for performing symbolic,
numeric, and graphical computations. For more information
on the toolbar icons, refer to the \refpages{worksheet/reference/WorksheetToolbar}
help page. At the core of the Maple computer algebra system is a powerful
programming language. For more information on clearing the Maple internal
memory and command, refer to the restart help page.
\end{document}
答案1
这里有解决方案:(a) 允许在字符串中任意换行;(b) 为字符串添加颜色和粗体。不过我不知道如何添加下划线部分。
% !TEX TS-program = lualatex
\documentclass{book}
\usepackage{fontspec,xcolor}
\usepackage{xurl}
\urlstyle{same}
\usepackage[colorlinks,allcolors=blue]{hyperref} % for \nolinkurl macro
\newcommand\cmdA[1]{\nolinkurl{#1}} % line-breaking
\newcommand\cmdB[1]{\textcolor{red}{\cmdA{#1}}} % coloring and line-breaking
\newcommand\cmdC[1]{\textbf{\cmdB{#1}}} % boldfacing, coloring, and line-breaking
\begin{document}
For more information on the toolbar icons, refer to the
\cmdA{worksheet/reference/WorksheetToolbar} help page.
For more information on the toolbar icons, refer to the
\cmdB{worksheet/reference/WorksheetToolbar} help page.
For more information on the toolbar icons, refer to the
\cmdC{worksheet/reference/WorksheetToolbar} help page.
\end{document}