diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/coloring/README | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/coloring/coloring-doc.pdf | bin | 0 -> 26014 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/coloring/coloring-doc.tex | 99 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/coloring/coloring.sty | 115 |
4 files changed, 225 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/coloring/README b/Master/texmf-dist/doc/latex/coloring/README new file mode 100644 index 00000000000..ddae9575059 --- /dev/null +++ b/Master/texmf-dist/doc/latex/coloring/README @@ -0,0 +1,11 @@ +Package coloring: define missing colors by their names +Copyright (C) 2016 Zou Hu <zohooo@yeah.net> + +Please report bugs, problems, and suggestions via + https://github.com/zohooo/coloring + +The package may be distributed and/or modified under the conditions +of the LaTeX Project Public License, either version 1.3 of this +license or (at your option) any later version. The latest version +of this license is in + http://www.latex-project.org/lppl.txt diff --git a/Master/texmf-dist/doc/latex/coloring/coloring-doc.pdf b/Master/texmf-dist/doc/latex/coloring/coloring-doc.pdf Binary files differnew file mode 100644 index 00000000000..6a31590dfe8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/coloring/coloring-doc.pdf diff --git a/Master/texmf-dist/doc/latex/coloring/coloring-doc.tex b/Master/texmf-dist/doc/latex/coloring/coloring-doc.tex new file mode 100644 index 00000000000..35672abc19f --- /dev/null +++ b/Master/texmf-dist/doc/latex/coloring/coloring-doc.tex @@ -0,0 +1,99 @@ +% -*- coding: utf-8 -*- +% !TEX program = xelatex + +\documentclass[14pt]{beamer} + +\usepackage{coloring} +\usetheme[color=green]{epyt} % https://www.ctan.org/pkg/epyt + +\usepackage{arev} % use arev sans font + +\hypersetup{ + pdfpagemode={FullScreen}, +} + +\usepackage{listings} +\lstset{basicstyle=\ttfamily\color{rgbx55}} + +\usepackage{tabu} + +\AtBeginDocument{ + \setlength{\parskip}{5pt plus 1pt minus 1pt} + \setlength{\baselineskip}{19pt plus 1pt minus 1pt} + \setlength{\lineskiplimit}{4pt} + \setlength{\lineskip}{4pt} +} + +\begin{document} + +\title{LaTeX Package Coloring} +\author{zohooo@yeah.net} +%\institute{https://github.com/zohooo/coloring} + +\begin{frame}%[plain] +\transboxout +\titlepage +\end{frame} + +\begin{frame}[fragile]{Introduction} +The \verb|coloring| package makes it possible to define colors automatically by their names. +\begin{itemize} + \item It's useful in drawing a \verb|tikz| picture. + \item It's useful in designing a \verb|beamer| theme. +\end{itemize} +Using the package, you \alert{don't} need to write \verb|\definecolor| before using a color. +\end{frame} + +\begin{frame}[fragile]{Example One: Gray Colors} +When you write +\begin{lstlisting} +\textcolor{gray2}{Text} +\end{lstlisting} +The package will automatically define the following \alert{gray} color for you +\begin{lstlisting} +\definecolor{gray2}{gray}{0.2} +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile]{Example Two: RGB Colors} +When you write +\begin{lstlisting} +\colorbox{rgb37x}{Text} +\end{lstlisting} +The package will automatically define the following \alert{rgb} color for you +\begin{lstlisting} +\definecolor{rgb37x}{rgb}{0.3,0.7,1.0} +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile]{Example Three: HSB Colors} +When you write +\begin{lstlisting} +\colorlet{mycolor}{blue59} +\end{lstlisting} +The package will automatically define the following \alert{hsb} color for you +\begin{lstlisting} +\definecolor{blue59}{Hsb}{240,0.5,0.9} +\end{lstlisting} +You may add the following line to the preamble when using hsb colors +\begin{lstlisting} +\substitutecolormodel{hsb}{rgb} +\end{lstlisting} +\end{frame} + +\def\mycolor#1{\noindent\color{black}\fcolorbox{gray}{#199}{\strut#1}} +\begin{frame}{HSB Colors} +\begin{center} +\begin{tabu}{|r|X||r|X|}\hline + Hue & Name & Hue & Name \\\hline + 0 & \mycolor{red} & 180 & \mycolor{cyan} \\\hline + 30 & \mycolor{brown} & 210 & \mycolor{azure} \\\hline + 60 & \mycolor{yellow} & 240 & \mycolor{blue} \\\hline + 90 & \mycolor{olive} & 270 & \mycolor{violet} \\\hline + 120 & \mycolor{green} & 300 & \mycolor{magenta} \\\hline + 150 & \mycolor{teal} & 330 & \mycolor{purple} \\\hline +\end{tabu} +\end{center} +\end{frame} + +\end{document} diff --git a/Master/texmf-dist/tex/latex/coloring/coloring.sty b/Master/texmf-dist/tex/latex/coloring/coloring.sty new file mode 100644 index 00000000000..95b18964ebd --- /dev/null +++ b/Master/texmf-dist/tex/latex/coloring/coloring.sty @@ -0,0 +1,115 @@ +% -*- coding: utf-8 -*- + +\ProvidesPackage{coloring}[2016/05/11 v0.2] + +\RequirePackage{xcolor,etoolbox,xparse,l3regex} + +\makeatletter + +\def\colorring@hack#1{\@ifundefined{\string\color@#1}{\coloringdefine{#1}}{\relax}} + +% hacking \definecolor and \colorlet in xcolor +\pretocmd{\@declaredcolor}{\colorring@hack{#1}}{}{} +\pretocmd{\XC@col@rlet}{\colorring@hack{#4}}{}{} + +% hacking \define@key{beamerthc}{fg} and \define@key{beamerthc}{bg} in beamer +\catcode`\#=12 +\def\coloring@hack@beamer{% + \pretocmd{\KV@beamerthc@fg}{\colorring@hack{#1}}{}{}% + \pretocmd{\KV@beamerthc@bg}{\colorring@hack{#1}}{}{}% +} +\catcode`\#=6 +\@ifclassloaded{beamer}{\coloring@hack@beamer}{}{} + +\makeatother + +\ExplSyntaxOn + +% local variables for gray colors +\tl_new:N \l_coloring_gray_tl + +% local variables for rgb colors +\tl_new:N \l_coloring_r_tl +\tl_new:N \l_coloring_g_tl +\tl_new:N \l_coloring_b_tl + +% local variables for hsb/hsv colors +\int_new:N \l_coloring_h_int +\tl_new:N \l_coloring_s_tl +\tl_new:N \l_coloring_v_tl + +\clist_new:N \l_coloring_hue_name_clist +\clist_set:Nn \l_coloring_hue_name_clist + { + red, % 0 + brown, % 30 + yellow, % 60 + olive, % 90 + green, % 120 + teal, % 150 + cyan, % 180 + azure, % 210 + blue, % 240 + violet, % 270 + magenta, % 300 + purple % 330 + } + +\NewDocumentCommand \coloringdefine { m } +{ + % define gray colors + \coloring_define_gray:n { #1 } + % define rgb colors + \coloring_define_rgb:n { #1 } + % define hsb colors + \int_set:Nn \l_coloring_h_int { 0 } + \clist_map_inline:Nn \l_coloring_hue_name_clist + { + \coloring_define_hsb:nnn { \l_coloring_h_int } { ##1 } { #1 } + \int_add:Nn \l_coloring_h_int { 30 } + } +} + +\cs_new_protected_nopar:Npn \coloring_define_gray:n #1 +{ + \regex_extract_once:nnNT { \A gray([0-9x]) \Z } { #1 } \l_coloring_temp_seq + { + \seq_pop_right:NN \l_coloring_temp_seq \l_coloring_gray_tl + \coloring_set_value:N \l_coloring_gray_tl + \definecolor {#1} {gray} {\l_coloring_gray_tl} + } +} + +\cs_new_protected_nopar:Npn \coloring_define_rgb:n #1 +{ + \regex_extract_once:nnNT { \A rgb([0-9x])([0-9x])([0-9x]) \Z } { #1 } \l_coloring_temp_seq + { + \seq_pop_right:NN \l_coloring_temp_seq \l_coloring_b_tl + \seq_pop_right:NN \l_coloring_temp_seq \l_coloring_g_tl + \seq_pop_right:NN \l_coloring_temp_seq \l_coloring_r_tl + \coloring_set_value:N \l_coloring_b_tl + \coloring_set_value:N \l_coloring_g_tl + \coloring_set_value:N \l_coloring_r_tl + \definecolor {#1} {rgb} {\l_coloring_r_tl, \l_coloring_g_tl, \l_coloring_b_tl} + } +} + +\cs_new_protected_nopar:Npn \coloring_define_hsb:nnn #1 #2 #3 +{ + \regex_extract_once:nnNT { \A #2([0-9x])([0-9x]) \Z } { #3 } \l_coloring_temp_seq + { + \seq_pop_right:NN \l_coloring_temp_seq \l_coloring_v_tl + \seq_pop_right:NN \l_coloring_temp_seq \l_coloring_s_tl + \coloring_set_value:N \l_coloring_v_tl + \coloring_set_value:N \l_coloring_s_tl + \definecolor {#3} {Hsb} {\int_use:N #1, \l_coloring_s_tl, \l_coloring_v_tl} + } +} + +\cs_new_protected_nopar:Npn \coloring_set_value:N #1 +{ + \tl_set:Nn \l_tmpa_tl { x } + \tl_if_eq:NNTF #1 \l_tmpa_tl { \tl_set:Nn #1 {1} } { \tl_set:Nx #1 {.#1} } +} + +\ExplSyntaxOff |