4

Solving recently a problem with coloured table and hhline, I found that, as the babel-spanish module makes > and < active characters, using codes such as \hhline{>{\arrayrulecolor{some colour}}--} doesn't work: the line remains black.

A workaround consists in inactivating these characters with \shorthandoff. However, the same type of construction in the preamble of a tabular environment does work, so I wondered whether it should not be reported as a bug in hhline.

Here is a very short code demonstrating this behaviour:

\documentclass[spanish, table]{article}%
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{array}
\usepackage{hhline}
\usepackage[table]{xcolor}
\parindent = 0pt

\begin{document}

Without \verb|\shorthandoff|: \medskip

\begin{tabular}{| >{\bfseries}cc|}
  \hhline{--}
  Some text & Some other text
  \\
  \hhline{>{\arrayrulecolor{red}}->{\arrayrulecolor{blue}}-}
\end{tabular}
\vspace{1cm}

With \verb|\shorthandoff{<>}|: \medskip

\shorthandoff{<>}\begin{tabular}{|>{\bfseries}cc|}
  \hhline{--}
  Some text & Some other text
  \\
 \hhline{>{\arrayrulecolor{red}}->{\arrayrulecolor{blue}}-}
\end{tabular}

\end{document} 

enter image description here

  • 3
    I could have a look but in general packages making characters active will stop those characters being used as delimiters in other commands so you could make a feature request but it's not a bug – David Carlisle Jun 16 '17 at 21:11
  • @David Carlisle: I used the bug wording because I didn't find the relevant wording, and no one ever pointed it. I meant that probably you didn't notice there was a problem, so didn't care for it. What puzzles me is there's no problem in the preamble of the table. – Bernard Jun 16 '17 at 22:08
  • Shorthands are deactivated in the preamble by default, which explains the behaviour you found. – Javier Bezos Jun 17 '17 at 11:43
  • @JavierBezos: You mean they're activated by default, or did I misunderstand the whole thing? It works after I've set`\shorthandsoff{<>}`` . – Bernard Jun 17 '17 at 11:48
  • @Bernard Sorry. I missed ‘of a tabular environment’ (in other words, I thought it was the document preamble). Just ignore my comment. – Javier Bezos Jun 17 '17 at 14:09
1

colortbl's version of \hhline could be made to take more care of active characters as follows:

enter image description here

\documentclass[spanish, table]{article}%
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{array}
\usepackage{hhline}
\usepackage[table]{xcolor}
\parindent = 0pt

{\makeatletter
\catcode`\>\active
\catcode`\-\active
\gdef\hhline#1{\omit\@firstamptrue\@tempswafalse
\global\setbox\@ne\HH@box\doublerulesep\doublerulesep
  \expandafter\let\expandafter>\string>%
  \expandafter\let\expandafter-\string-%
  \xdef\@tempc{\ifx\extrarowheight\HH@undef\hskip\string-.5\arrayrulewidth\fi}%
    \HH@xexpast\relax#1*0x\@@\toks@{}\expandafter\HH@let\@tempa`}
}

\begin{document}

Without \verb|\shorthandoff|: \medskip

\begin{tabular}{| >{\bfseries}cc|}
  \hhline{--}
  Some text & Some other text
  \\
  \hhline{>{\arrayrulecolor{red}}->{\arrayrulecolor{blue}}-}
\end{tabular}
\vspace{1cm}

With \verb|\shorthandoff{<>}|: \medskip

\shorthandoff{<>}\begin{tabular}{|>{\bfseries}cc|}
  \hhline{--}
  Some text & Some other text
  \\
 \hhline{>{\arrayrulecolor{red}}->{\arrayrulecolor{blue}}-}
\end{tabular}

\end{document} 

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.