7

I have using pdflatex to get the color environment text. But when using htlatex the color and the environment content (Note) is not converting. Please find the MWE below:

\documentclass{book}
\usepackage{xcolor}
\definecolor{midblue}{cmyk}{1,0,0.16,0.09}
\newcommand{\notefont}{\small\sffamily\color{midblue}}
\newenvironment{notelist}{%
\begin{itemize}
   \item[\label={\notefont Note:}]
}{%
 \end{itemize}%
}

\begin{document}

\chapter{Chapter Title Here}
\begin{notelist}
\item A template for fractions may be obtained by pressing.
\end{notelist}
\begin{notelist}
\item For all calculations you can also use the \textbf{Scratchpad}.
\item For details of the use of the Scratchpad and general use of the calculator with
operating system 3.0 refer to the Appendix Computer Algebra System (TI-Nspire).
\end{notelist}
\end{document}

How to get the color environment and colored framebox environement in htlatex?

9

Colors are supported by tex4ht but there are two points:

\color command isn't supported:

The \Verb!\color{red}! instruction might be problematic since it does not on its own determine the extent of the text to be colored. As a result, its effect can cross logical boundaries. That is against the philosophy of markup languages in general and of XML in particular.

It is possible to implement the \Verb!\color{...}! feature but I'm not sure it is desirable to do so. I think it is preferable to expect users to use commands of the form \Verb!\textcolor{red}{...}! for code fragments.

so it is better to use \textcolor

each color has to be declared for tex4ht with command in the form:

 \Configure{HColor}{colorname}{csscode}

Now back to your code. I think that:

\begin{itemize}
   \item[\label={\notefont Note:}]
}{%

is wrong, you are calling \label command with = as argument. It should be:

\begin{itemize}
   \item[{\notefont Note:}]
}{%

but this doesn't work with tex4ht for some reason. But there is also no reason to use \item this way, you may just define notelist environment this way:

\definecolor{notecolor}{cmyk}{1,0,0.16,0.09}
\newenvironment{notelist}{%
  \leavevmode\noindent{\notefont\textcolor{notecolor}{Note:}}
  \begin{itemize}
}{%
 \end{itemize}%
}

We defined notecolor to be used here, because I think it is better to use logical names, it will enable you to change the color easily in the future. Now you need to create a custom config file and put these declarations:

\Preamble{xhtml}

\newcommand\colortohtml[2]{%
\extractcolorspec{#1}{\tmp}%
\expandafter\convertcolorspec\tmp{HTML}#2
}
\newcommand\declarehcolor[1]{%
\colortohtml{#1}\tmp%
\Configure{HColor}{#1}{\#\tmp}%
}
\declarehcolor{notecolor}
\begin{document}
\EndPreamble

commands from xcolor package are used here to convert named color to rgb value. note that when you use cmyk colors, the resulting color may be slightly different due to the conversion.

Now compile the file with

htlatex filename cfgname

enter image description here

  • How do achieve framebox from For all calculations.... to end of (TI-Nspire). (Including itemize). – Balaji Aug 18 '14 at 7:36
  • @Balaji could you post some example of what you have in mind? – michal.h21 Aug 18 '14 at 8:21
  • I will post in new question. – Balaji Aug 18 '14 at 9:06
  • I do not think one can use \textcolor everywhere. How would you use it in a column specification? Like in >{\color{red}}c to color and center a given column in a tabular environment? – Máté Wierdl Dec 14 '16 at 20:12
  • @user29363 of course not everywhere, for tables or color boxes you need to use different means. \textcolor should be used only for marking colorized chunk of text – michal.h21 Dec 14 '16 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.