Package: highlight
Version: 2.2.8-1
Severity: normal
Tags: sid

For the purposes of this bug report, assume '\' is a literal character
and not an escape character.  Also, the patch at the bottom of this
email is only representative of what could be done.

Highlight uses "\\" for newlines in the LaTeX output.  This causes
problems when the input source code has blank lines and highlight
encodes these as "\\".  If you run pdflatex, you'll see this type of
message:

  Underfull \hbox (badness 10000) in paragraph at lines 29--41
  Underfull \hbox (badness 10000) in paragraph at lines 29--41
  Underfull \hbox (badness 10000) in paragraph at lines 29--41

The first two correspond to blank lines in my input file.  The last
one is from "\mbox{}\\" near the end of the generated output.

If you put the LaTeX output into its own file and use "\input" to
include the file (after moving some of the headers and footer to the
main file), then it generates a LaTeX error:

  ! LaTeX Error: There's no line here to end.

  See the LaTeX manual or LaTeX Companion for explanation.
  Type H <return> for immediate help.

This is from the TeX FAQ
(http://www.tex.ac.uk/cgi-bin/texfaq2html?label=noline):

  \\ is actually a rather bad command to use in this case
  (even if it worked), since it would force the 'paragraph' that's made
  up of the text of the item to terminate a line which has nothing on
  it but the label. This would lead to an "Underfull \hbox" warning
  message (usually with 'infinite' badness of 10000); while this
  message doesn't do any actual harm other than slowing down your LaTeX
  run, any message that doesn't convey any information distracts for no
  useful purpose.

A work around given in the FAQ is to use "\hspace*{\fill}\\" instead of
just "\\".

With a quick glance at the code, it looks like line 42 of
highlight-2.2.8/highlight/latexgenerator.cpp is where the change could
be made.  I also removed a hardcoded newline in "mbox{}\\" because
that was causing a similar problem.

I didn't read the rest of the code so this may break other parts of the
code.  You only need to make this change when the input line is blank
so this newLineTag change is overkill because there are other areas
where a '\\' is fine at the end of a line.

With these changes, however, I can run both the standalone version
and \input included version without warnings.


--- highlight-2.2.8/highlight/latexgenerator.cpp.orig   2005-02-19 12:00:37.0000
00000 -0500
+++ highlight-2.2.8/highlight/latexgenerator.cpp        2005-02-24 13:49:23.1230
27816 -0500
@@ -39,7 +39,7 @@ LatexGenerator::LatexGenerator(const str
    styleTagClose.push_back( "}");
   }
 
-  newLineTag = "\\\\\n";
+  newLineTag = "\\hspace*{\\fill}\\\\\n";
   spacer = "\\ ";
 
   maskWs=true;
@@ -89,8 +89,8 @@ void LatexGenerator::printBody()
 
   processRootState();
 
-  *out << "\\mbox{}\\\\"
-       << "\n\\normalfont\n";
+  *out << "\\mbox{}\n"
+       << "\\normalfont\n";
 }
 
 string LatexGenerator::getHeader(const string & title)


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to