2

I ve been trying many solutions found on stack exchange to have a command that make bold the first letter of a word. All of them work. With every solution I have tried I have an hyphenation problem with the word having the first letter bolded. It seems that the hyphenation cannot be done (as shown on the picture with de word Désambiguisation at the end of the first line).

enter image description here

Do you have any other alternative to have first bold letter while considering hyphenation ?

1
  • 3
    Welcome to TeX.SX! A run of letters is never considered for automatic hyphenation if the font changes in between. You have to do it manually, in these cases. Can you add a minimal example of code?
    – egreg
    Sep 16 '15 at 9:42
2

The problem is that words subject to automatic hyphenation must be formed with letters in the same font (LuaTeX has not this limitation).

I don't know what macro you're using for emboldening the first letter, so I'll make one on the spot.

Automatic hyphenation is reenabled after the initial, but of course this could lead to wrong results; if false hyphenation results, add \- in the appropriate spots. For languages such as French or Italian, where hyphenation is mostly at syllable boundaries and syllables are defined grammatically, it shouldn't be a big problem, except in case the word has some prefix that should be taken care of by hyphenation in “nonstandard” way. Which might be the case with Désambiguïsation.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}

\newcommand{\fb}[1]{\dofb#1}
\newcommand{\dofb}[1]{\textbf{#1}\nobreak\hspace{0pt}}

\begin{document}

Dans notre approche, nous avons défini quatre types de
méta critère: \fb{Désambiguïsation}, \fb{Temporel},
\fb{Contenu} et \fb{Autre}. Pour évaluer l'apport de
chacun des types de méta critère que nous avons mis en
place, nous avons évalué notre système sur toutes les
possibilités d'association (\mbox{c.-à-d.}, 15~possibilités).

\end{document}

enter image description here

Warning

In my opinion you should not allow automatic hyphenation in these cases. Since you're not going to use this first-letter-bold words very often, leave to the final revision where to appropriately add \-.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}

\newcommand{\fb}[1]{\dofb#1}
\newcommand{\dofb}[1]{\textbf{#1}}

\begin{document}

Dans notre approche, nous avons défini quatre types de
méta critère: \fb{Désam\-biguïsation}, \fb{Temporel},
\fb{Contenu} et \fb{Autre}. Pour évaluer l'apport de
chacun des types de méta critère que nous avons mis en
place, nous avons évalué notre système sur toutes les
possibilités d'association (\mbox{c.-à-d.}, 15~possibilités).

\end{document}
0

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.