1

In below code, I define two commands \refpage and \refpages using in turn, the ulem and soul packages, but both of them do not break a sentence when that sentence runs on beyond the end of a line.

    \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}

Output: enter image description here

3
  • What's your question? And what's your ultimate typesetting objective? E.g., are you looking to make the string into a clickable hyperlink?
    – Mico
    Mar 22, 2022 at 6:13
  • @Mico, I want underline special sentence and break it when that sentence stay on the end of line.
    – niksirat
    Mar 22, 2022 at 6:44
  • Bit of a long shot: Have you tried soulpos?
    – Ingmar
    Mar 22, 2022 at 7:27

1 Answer 1

1

Here's a solution that (a) enables arbitrary line breaks in the string and (b) colors and bold-faces the string. I don't know how to do the underlining part, though.

enter image description here

% !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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .