Bug 340213 - Black color coding in Latex export
Summary: Black color coding in Latex export
Status: RESOLVED FIXED
Alias: None
Product: kig
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: David E. Narvaez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-21 21:12 UTC by Grzegorz Wierzchowski
Modified: 2014-10-25 03:13 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.14.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grzegorz Wierzchowski 2014-10-21 21:12:39 UTC
If drawing is exported to Latex format (see steps for more details) the line (or other objects) which has set color as black are being saved in output file as:
\draw[color={rgb:red,0;green,0;blue,0}, line width=0.5pt, solid] (-2.59,1.23) -- (2.60,-1.79);
The part "color={rgb:red,0;green,0;blue,0}" creates problem for Latex version as of Ubuntu 14.04:
After such files is included in latex document pdflatex raises error: "arithmetic overflow" or so, and final pdf file is not generated.
My investigation showed that replacing part in qustion with: "color=black" resolves problem (i.e. pdflatex correctly comlipe the file).
AFAIK problem only happens with pure black color (all RGB compoments eq zero).

Reproducible: Always

Steps to Reproduce:
1.Open Kig and create any drawing
2.For one of the objects (e.g. segment) set color as black.
3.Choose File/Export To/Latex menu and enter filename: bug.tex
4.On latex options dlalog leave defaults (i.e. format Tikx/PGF)
5.Create .tex master document; in its preambule declare \usepackage{tikz}; in the body include our exported graph, e.g.
\parbox{0.5\textwidth}{\input{bug}}
6. BUG: Try compiling master document either directly with pdflatex or thru some IDE like Kile. You will get error:
! Arithmetic overflow. <recently read> \@tempcntb                      
l.14 ... (-3.62675,0.524092) -- (1.97934,1.18797);
7. Replace color specification in bug.tex file as sugested in Details section
8. Now Latex document compiles without error and picture is visible in PDF

Actual Results:  
File exported from Kig and Imported to Latex does not compile

Expected Results:  
I know that root cause is in Latex or rather tikz package, but:
While exporting to Tikz, I would propose to use predefined color aliases (black, red, blue, green, gray, etc.) for objects which colors were set thru direct menu option and full RGB notation for colors set thru color picker dialog.
This sounds like latex bug workaround, but will also improve exported files readability.
Comment 1 Christoph Feck 2014-10-21 23:56:39 UTC
https://git.reviewboard.kde.org/r/120703/
Comment 2 David E. Narvaez 2014-10-25 03:13:26 UTC
Git commit 6d32511f19aaa8e9e9c75b12cef75d94a9acdfa3 by David E. Narvaez.
Committed on 25/10/2014 at 02:44.
Pushed by narvaez into branch 'KDE/4.14'.

Specify RGB Divisor Explicitly in the color Key

The documentation of xcolor explains that this key is not about red,
green and blue in a scale of 255, but in a scale defined either by the
sum of all the values or an explicit scale indicated by the syntax. If
the sum of all the values is 0, like in the bug report, then it causes
an arithmetic overflow; yet, besides this bug, the wrong interpretation
causes another issue when setting an object color to white (which is
probably why this was not spotted before): the color will be interpreted
as (0.33,0.33,0.33) in RGB.
FIXED-IN: 4.14.3

M  +1    -1    filters/pgfexporterimpvisitor.cc

http://commits.kde.org/kig/6d32511f19aaa8e9e9c75b12cef75d94a9acdfa3