Npm Color Package

0 views
Skip to first unread message

Louella Kammann

unread,
Aug 5, 2024, 8:32:30 AM8/5/24
to stewunnorfi
Thisarticle explains how to use color in your LaTeX document via the color or xcolor packages. Note that user-level documentation of the color package is contained in The LaTeX standard graphics bundle.

Specifically, the output file typeset by Overleaf is converted to SVG using a program called dvisvgm, which is part of TeX Live and available on our servers. To run dvisvgm, after the page is typeset, we use a latexmkrc file which is created when you open the following code in Overleaf:


The command \definecolor takes three parameters: the name of the new color, the model, and the color definition. Roughly speaking, each number represent how much of each color you add to the mix that makes up the final color.


Colors defined by either model can later be used within your document not only to set the color of the text, but for any other element that takes a color as parameter, for instance tables (you must add the table option to xcolor), graphic elements created with TikZ, plots, vertical rulers in multicolumn documents and code listings.


The command \pagecolorblack set the page color to black. This is a switch command, meaning it will take effect in the entire document unless another switch command is used to revert it. \nopagecolor will change the background back to normal.


This package is mentioned because it has color highlighting features. It applies the advanced capabilities of LuaTeX to provide underlining, strikethough, and highlighting using methods in which kerning is not affected, underlined text can use arbitrary commands, hyphenation works and ligatures are preserved.


Here, we'll demonstrate using luacolor to colorize text typeset in Hindi and Arabic together with diacritics used on a Latin script (based on this example). The following example uses the babel package to configure LuaLaTeX to typeset Hindi and Arabic using fonts present on Overleaf.


The color package provides both foreground (text, rules, etc.) and background colour management; it uses the device driver configuration mechanisms of the graphics package to determine how to control its ouptut.


Note: I only use the packages to add a little bit of color here and there to my documents. I'm by no means an advanced user, but I want to know which of the packages are preferred and for what reasons.


Edit: The xcolor package documentation states: Its purpose can be summarized as to maintain the characteristics of color, while providing additional features and flexibility with (hopefully) easy-to-use interfaces.


Adding colors to your text is supported by the xcolor package (supersedes package color). Using this package, you can set the font color, text background, or page background. You can choose from predefined colors or define your own colors using RGB, Hex, or CMYK. Mathematical formulas can also be colored.


The package allows you to use the names of 19 base colors (black, white, blue, green, yellow, red etc.); these names are always available. Besides, the package has some options to get more predefined colors, which should be added globally. dvipsnames allows you to access more than 60 colors, and svgnames allows access to about 150 colors. If you need more color names, then you may also want to look at the x11names option that offers more than 300 colors.


The difference between\textcolorand\coloris the same as that between\textttand\ttfamily,you can use the one you prefer. The \color environment allows the text to run over multiple lines and other text environments whereas the text in \textcolor must all be one paragraph and not contain other environments.


Be wary that the below color names are case-sensitive. For example, \colorolivegreen raises an "undefined color" error, but \colorOliveGreen works fine. Table can be sorted by color name, by hue, by saturation, or by lightness.


Define the colors in the preamble of your document. (Reason: do so in the preamble, so that you can already refer to them in the preamble, which is useful, for instance, in an argument of another package that supports colors as arguments, such as the listings package.)


Normally one would predeclare all the colors as above, but sometimes it is convenient to directly use a color without naming it first. To achieve this, \color and \textcolor have an alternative syntax specifying the model in square brackets, and the color specification in curly braces. For example:


Image processing suites like the free GIMP suite for Linux/Windows/Mac offer color picker facilities to capture any color on your screen or synthesize colors directly from their respective rgb / hsv / hexadecimal values.


Spot colors are customary in printing. They usually refer to pre-mixed inks based on a swatchbook (like Pantone, TruMatch or Toyo). The package colorspace extends xcolor to provide real spot colors (CMYK and CIELAB). They are defined with, say:


At work, I've developed an internal package to standardize some analysis across the team. Mostly this consists of commonly used functions. I'd also like to add a few ggplot themes and color palettes to this package, but these aren't functions, they're objects.


Everything in R is an object, including functions, so I don't think you need to do anything special to handle non-function objects in packages. For example, see MASS::abbey, which is just a numeric vector.


That said, for consistency on the themes, I think it makes sense to make them a function, just like theme_bw(). It will be less confusing to end-users, wondering why they need () after theme_bw but not my_theme. This is partially covered here:

-ggplot2.html


But I think this blog post covers the details a little better:

flovv.github.io How to create a ggplot Theme - Unicorn EditionThemes are an convenient way to give ggplot charts an individualized, sometimes stylish look. Most of the time, I rely on the ggthemes package and the Economist style. Last week colleagues asked me to change the look of my charts. We joked around and...


If you want to have your internal package automatically set the default color scales and theme you can do so by setting them in .onAttach. This will change the defaults automatically anytime your package is attached with library(), so the results will be reproducible in the future. This code assumes ggplot2 is in your internal packages Depends, and you need to assign the scales in the global (rather than package) environment.


JPEG, VP8, the MPEG family and other codecs use this color model. Suchcodecs often use the terms YUV and Y'CbCr interchangeably, but strictlyspeaking, the term YUV applies only to analog video signals, and Y' (luma)is Y (luminance) after applying gamma correction.


viridis,and its companion package viridisLiteprovide a series of color maps that are designed to improve graphreadability for readers with common forms of color blindness and/orcolor vision deficiency. The color maps are also perceptually-uniform,both in regular form and also when converted to black-and-white forprinting.


viridisLite provides the base functions for generatingthe color maps in base R. The package is meant to be aslightweight and dependency-free as possible for maximum compatibilitywith all the R ecosystem. viridisprovides additional functionalities, in particular bindings forggplot2.


The color maps viridis, magma,inferno, and plasma were created by Stfan vander Walt (@stefanv) and Nathaniel Smith (@njsmith). If you want to know more aboutthe science behind the creation of these color maps, you can watch thispresentation ofviridis by their authors at SciPy 2015.


The color map turbo was developed by Anton Mikhailov toaddress the shortcomings of the Jet rainbow color map such as falsedetail, banding and color blindness ambiguity. More infor aboutturbo can be found here.


SPM doesn't have support for that directly, but you might be able to write a build plug-in that does the same invocation (look at Xcode's build log to see what flags it's passing) and then wire that source file into the rest of the build.


From what I'm seeing build logs have a Generate asset symbols invocation for each Swift Package target (when building an Xcode based target that links to packages or in isolation), and for some reason not only --generate-swift-asset-symbols is passed when actool is called for them but also --generate-swift-asset-symbol-extensions NO which disables the generation of symbol extensions.


Does anybody know if it's possible to turn off this symbol generation? It's causing conflicts with existing symbols in our code, and the quickest (temporary) workaround would be to disable this new generation. But, I don't think you can set a build setting like ASSETCATALOG_COMPILER_GENERATE_ASSET_SYMBOLS=NO via SPM.


I am also interested in this.

In addition, I would love to know how to get the ShapeStyle & Color extension generated for color resources that are part of an Xcode project. The "Asset symbol generation" does seem to be incomplete for Swift packages...


@Eirias asset generation is introduced to reduce these kinds of boiler codes. if we create these manual properties in the extension so what will be the benefit of using it? and in this approach manual work is still there


I can assure you that there's currently no way to change the access-level of generated assets to public. @Eirias's solution is currently the best out there in my opinion. We could possibly think of a Swift macro to apply on an enum and make these boilerplate automatically generated as well.


Asset catalogs now provide an inspector property for enabling system color and image accessors for generated asset symbols, which allows Swift packages to opt-in to generating these accessors. (113704993)


Color psychology plays a big role in advertising and retail sales. Package color has a notable effect on consumers and can turn them on to your product or chase them away. Depending on the demographics of your target market, the colors you choose to employ on you packaging materials can make or break the success of a product.

3a8082e126
Reply all
Reply to author
Forward
0 new messages