6

This question is related to How to create a newcommand for fontsize?. I would like to change the fontsize within \ul of the soul package. For example:

\newcommand{\mycfs}[1]{\fontsize{#1pt}{1.2#1pt}\selectfont} 
\soulregister{\mycfs}{1}

\ul{{\mycfs{6} Size 6 font} Normal size font}

This error message occurs: ! Package soul Error: Reconstruction failed.

How can this be fixed?

1
  • Have a look at the correction and additional answers to the other topic.
    – Stefan Kottwitz
    Commented Aug 23, 2010 at 19:00

2 Answers 2

4

I would change the definition of \mycfs so that it no longer has an argument:

\documentclass{book}
\usepackage{soul}

\newcommand\mycfs{\fontsize{\mysize}{\the\dimexpr \mysize*1.2\relax}\selectfont}
\newcommand\mysetsize[1]{\edef\mysize{#1pt}}
\soulregister{\mycfs}{0}

\begin{document}
\mysetsize{6}

\ul{\mycfs Size 6 font} Normal size font
\end{document}
1

\mbox could already fix it for you:

\documentclass{book}
\usepackage{soul}
\newlength{\mysize}
\newcommand{\mycfs}[1]{\setlength{\mysize}{#1pt}%
  \fontsize{\mysize}{1.2\mysize}\selectfont}
\begin{document}
text

\ul{\mbox{\mycfs{6}Size 6 font} Normal size font}

text
\end{document}

Output:

alt text

4
  • 1
    The trouble with mbox is that is will not line break properly and out out of the margin.
    – user942
    Commented Aug 23, 2010 at 21:16
  • What is the goal? Underlining long passages or several lines seems strange to me.
    – Stefan Kottwitz
    Commented Aug 23, 2010 at 21:22
  • 1
    underlining urls
    – user942
    Commented Aug 23, 2010 at 21:23
  • 2
    As underlining is typographically questionable style it's rarely used in texts, even modern webpages try to avoid that. It's a relic of the time of early browsers. So, it's not well supported. Perhaps have a look at tex.ac.uk/cgi-bin/texfaq2html?label=underline - maybe you might find a better emphasizing of URLs than underlining? Bold, colored, or typewriter font?
    – Stefan Kottwitz
    Commented Aug 23, 2010 at 21:48

You must log in to answer this question.

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