Proposal for color format
See original GitHub issueWhile working on #142, I’ve checked internet for documentation about how other LaTeX-related tools deal with colors. I have not found any evidence that LaTeX supports direct color definition (e.g. \color{rgb}{1.0,1.5,1.0}{mytext}
) for either \color
or \colorbox
. Although, I’ve found a useful piece of documentation on Wikibooks.
I don’t want to add ability to define new colors in WPF-Math LaTeX documents, so I don’t want to add commands such as \definecolor
. I believe that the markup should stay static at the moment and should not have any influence on itself (i.e. no macro or color or whatever definitions in markup).
So I suggest that we document and add a modified syntax for \color
and \colorbox
commands by adding an optional mode
parameter. Full syntax will be:
\command [mode] {color} {text}
Where:
command
is eithercolor
orcolorbox
mode
is one ofgray
,rgb
,RGB
,HTML
,cmyk
(for now let’s stop on that, but the code should be robust enough to add more modes: xcolor manual includes some additional modes)color
is either a predefined color name (as implemented already) if themode
argument wasn’t provided or a proper color definition according to the wikibooks documentation- additionally to the standard
color
definitions, we will support a transparency parameter that will be optional and should be added in a convenient manner to every mode we support
The motivation for adding transparency is clear: while LaTeX was designed to provide mostly a printed documents, we know that we’re working with display graphics in WPF-Math, and transparency could be useful and shouldn’t be too hard to implement, so I think we should add it.
Here’re some syntax samples:
\colorbox{red}{text} // already implemented, "red" is a predefined color name
\colorbox{red,0.5}{text} // predefined color with transparency
\colorbox[gray]{0.5}{text}
\colorbox[gray]{0.5, 0.5}{text} // added transparency; also note that embedded spaces should be supported
\colorbox[rgb]{0,0,0}{text}
\colorbox[rgb]{0,0,0, 0.5}{text}
\colorbox[RGB]{255,255,255}{text}
\colorbox[RGB]{255,255,255,0}{text}
\colorbox[HTML]{FFFFFF}{text}
\colorbox[HTML]{ffffff00}{text}
\colorbox[cmyk]{0,0,0,1}{text}
\colorbox[cmyk]{0,0,0,1,0.5}{text}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (8 by maintainers)
Top GitHub Comments
@B3zaleel you’ve already implemented the core of the feature, I’ll take care of the rest, don’t bother yourself 😃
In the command processing function, we could first check for a color model and read the next two arguments.