2

I would really appreciate if someone could help me with this. I don't know how to prevent the second phrase from not breaking at the end of the line. Surely, I can break the phrase on my own (third phrase), but then it doesn't fit the whole width of the text and I have to make it fit manually. I need Latex to take care of that line break. Apparently, the reason is contour package, but I do need its very bold font.

EDIT: I simplified my code. Sorry about that.

\documentclass[10pt]{article}
\usepackage[usenames]{color}
\usepackage[outline]{contour}

\definecolor{MIR}{RGB}{187, 30, 16}

\contourlength{0.3pt}
\contournumber{20}

\newcommand{\MIR}[1]{\contour{MIR}{#1}}

\begin{document}

I only need some text width enough to prove my point, so I'll write some nonsenses.

\MIR{I only need some text width enough to prove my point, so I'll write some nonsenses.}

\MIR{I only need some text width enough to prove my point, so I'll write}\linebreak \MIR{some nonsenses.} 
\end{document}
  • 1
    Aside: The problem does not appear to be related to the soul package and the \ul macro. Hence, you could (should?) probably simplify your minimum working example further by leaving out all \ul-related directives and not loading the soul package. – Mico Jan 30 '18 at 5:40
  • You can't have line breaks in contour. The main text is inside a \mbox{}. – Ulrike Fischer Jan 30 '18 at 10:51
1

You can't break lines in the scope of \contour. But you can split the words and apply \contour to each one.

\documentclass[10pt]{article}
\usepackage[usenames]{color}
\usepackage[outline]{contour}
\usepackage{xparse}

\definecolor{MIR}{RGB}{187, 30, 16}

\contourlength{0.3pt}
\contournumber{20}

\ExplSyntaxOn
\NewDocumentCommand{\MIR}{m}
 {
  \seq_set_split:Nnn \l_tmpa_seq { ~ } { #1 }
  \seq_map_inline:Nn \l_tmpa_seq { \contour{MIR}{##1} ~ } \unskip
 }
\ExplSyntaxOff

\begin{document}

I only need some text width enough to prove my point, so I'll write some nonsenses.

\MIR{I only need some text width enough to prove my point, so I'll write some nonsenses.}

\end{document}

enter image description here

|improve this answer|||||
  • 1
    This works but in my original code, I also use macro \ul from soul package combined with contour. With your code, I get words individually underlined. Is there a way to get a single underline? – Daniel Chávez Jan 30 '18 at 15:03
  • @DanielChávez I don't think so. – egreg Jan 30 '18 at 15:33
  • Okay. I think it's great the way it is now. Thank you so much. – Daniel Chávez Jan 31 '18 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.