Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When using French guillemets with TeX4HT, the resulting symbols are not followed/preceded by non-breaking spaces like they should, resulting in wrong line-breaking in HTML.

I tried resetting \og and \fg with a babel.4ht file, but I can't get anything working. The only solution I've found so far is the following:

I defined new \Og and \Fg commands with:

  \newcommand{\Og}{\HCode{« }}
  \newcommand{\Fg}{\HCode{ »}}

together with a sed hack to remove the spaces before  :

sed -i "s@ *  *@\ @g" $HTML

I'd like to get rid of this and do it properly in a .4ht file. How could I do this?


The \Og/\Fg hack is actually acceptable for me, but not the sed one, so I'm modifying the title of this question: How can I remove spaces before the command?

share|improve this question
I don't know TeX4HT (or even HTML for that matter), so I don't know if this comment is relevant, but the stringstrings package can do things like extract substrings, remove leading spaces, etc. You shuld be able to crop strings with it. – Steven B. Segletes Feb 22 '13 at 14:26
Thanks for the pointer. \removeleadingspaces from the stringstrings package allows to remove leading spaces indeed. However, it doesn't remove the spaces from the string before the \Fg call… – ℝaphink Feb 25 '13 at 13:03
I am trying to understand a concrete example of your need, but am having a hard time, because I am not fluent in your 4ht and html. I wrote stringstrings, so I have an interest in making it work for your need. Can you rephrase the problem with a MWE or in a more LaTeX'ey syntax? – Steven B. Segletes Feb 26 '13 at 1:56
Are there any news here? – Johannes_B May 12 at 20:42

1 Answer 1

You can use just \unskip to remove that unwanted space before  :


some text \og and more text \fg\ and again some text    

you can redefine \og and \fg either in the custom config file or in frenchb.4ht:


  \def\og{\HCode{« }}
  \def\fg{\unskip\HCode{ »}}

compile with

htlatex filename "hello,charset=utf-8" " -cunihtf -utf8"

the result:

<p class="noindent" >some text &laquo;&nbsp;and more text&nbsp;&raquo; and again some text
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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