3

I’m trying to draw a vertical line with thickness 1pt with nicematrix package, but I obtain error compilation... any help is welcome. Here is my code

\documentclass{report}
\usepackage{nicematrix}

\begin{document} \begin{center} \NiceMatrixOptions{custom-line ={letter =I,width = 1 pt}} \setlength{\arrayrulewidth}{1pt} \begin{NiceTabular}{cIcc} $A$ & $1$ & $2$ \ \hline $B$ & $3$ & $3$
\end{NiceTabular} \end{center} \end{document}

Thanks. C.W

  • Hi, @Charly Watson, and welcome to TeX.SE. Are you receiving this error message: Package nicematrix Error: The key 'custom-line' is unknown for the command(nicematrix) \NiceMatrixOptions. }? – FHZ Mar 30 '22 at 16:10
  • Hi @FHZ. Not exactly, my error message is the following:

    ‘NiceMatrix/RulesBis/width’ is unknown and is being ignored

    – Charly Watson Mar 30 '22 at 16:32

4 Answers4

5

The compilation error can be avoided using tikz to set the line in the custom-line I and the key line width.

The key total-width is then used to reserve the space for the new column/rule.

b

(with nicematrix.sty 2022/03/11 v6.8)

\documentclass{report}
\usepackage{nicematrix}
\usepackage{tikz}% added <<<<<<<<<<<<

\begin{document} \begin{center}

\NiceMatrixOptions { custom-line = {letter = I , tikz = {line width=5pt, red }, total-width=5pt }, % changed <<<<<< } \setlength{\arrayrulewidth}{1pt} \begin{NiceTabular}{cIcc} $A$ & $1$ & $2$ \ \hline $B$ & $3$ & $3$
\end{NiceTabular} \end{center} \end{document}

From the commented code

The key total-width must be used only when the key tikz is used. When used, the key total-width specifies the width of the rule: it will be used to reserve space (in the preamble of the array or in the command for the horizontal rules).

F. Pantigny
  • 40,250
Simon Dispa
  • 39,141
  • +1 for letting explicit the need of version. I was working with version 5.13. Thanks. – FHZ Mar 30 '22 at 17:51
3

I reproduce below some examples from CTAN -- nicematrix with a few alterations.

The command custom-line appears at

  • 5.6 Commands for customized rules

where the given example starts with: \begin{NiceTabular}{lcIcIc}[custom-line = {letter=I, color=blue}] and in the sequence there is another example with TikZ and \NiceMatrixOptions. Unfortunately, both examples gave me the following error message: Package nicematrix Error: The key 'custom-line' is unknown for the(nicematrix) environment {NiceTabular}. ...cIc}[custom-line = {letter=I, color=blue}].

However, there is a way around. Sections:

  • 5 The rules
    • 5.2 The thickness and the color of the rules
    • 5.3.2 The keys hvlines and hvlines-except-borders

present commands rules/color and rules/width, that might be useful, but are not exactly a new custom-line you may define for the whole document and use it where you want.

A MWE follows

\documentclass{article}
\usepackage{nicematrix}

\begin{document} \begin{NiceTabular}{c|c|c}[rules/color=blue,rules/width=3pt] \hline rose & tulipe & lys \ arum & iris & violette \ muguet & dahlia & souci \ \hline \end{NiceTabular}

\setlength{\arrayrulewidth}{1pt} \begin{NiceTabular}{cccc}[hvlines,rules/color=green!50!black,rules/width=4pt] rose & tulipe & marguerite & dahlia \ violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \ pervenche & & & lys \ arum & iris & jacinthe & muguet \end{NiceTabular} \end{document}

enter image description here

FHZ
  • 3,939
  • I still may check how to define the new column line type globally, although I'm not an expert in this package. This answer is more a quick fix than a definite approach to the problem, or even an explanation why your problem appears. – FHZ Mar 30 '22 at 16:38
  • Many thanks @FHZ. But I want only one vertical rule with different thickness... your solution give all rules (both vertical and horinzontal) with the same thickness (3pt and 4pt) – Charly Watson Mar 30 '22 at 16:39
  • Indeed. I'm not sure, but you will probably have to use another solution or package. Check this for example. – FHZ Mar 30 '22 at 16:43
  • 1
    And maybe you could edit your question presenting your need for defining multiples rule styles and using them along the document. – FHZ Mar 30 '22 at 16:44
3

A small variation of the nice {Simon Dispa answer (+1):

\documentclass[border=3.14152, varwidth]{standalone}
\usepackage{nicematrix,tikz}
\usetikzlibrary{decorations.pathmorphing}
\NiceMatrixOptions
{custom-line = {letter = I,
                tikz = {},   % <---
                width = 2mm} % <---
}

\begin{document} [ \setlength{\arrayrulewidth}{1pt} \begin{NiceTabular}{cIcc} A & 1 & 2 \ \hline B & 3 & 3 \end{NiceTabular} ] \end{document}

enter image description here

Zarko
  • 296,517
0

Some edit in your code:

\documentclass{report}
\usepackage{nicematrix}

\begin{document} \begin{center} % \NiceMatrixOptions{custom-line ={letter =I,width = 1 pt}} \setlength{\arrayrulewidth}{1pt} \begin{NiceTabular}{c|cc} %<-- changed $A$ & $1$ & $2$ \ \hline $B$ & $3$ & $3$
\end{NiceTabular} \end{center} \end{document}

Output:

enter image description here

  • 1
    It doesn't seem to answer OP's question. Package nicematrix presents a custom-line command with I as column separator. In your answer, you just removed letter I for the conventional column separator |. – FHZ Mar 30 '22 at 16:09