The arydshln package^{∗}

Hiroshi Nakashima (Toyohashi Univ. of Tech.)

2000/07/04

Abstract

This file gives L^{A}TEX’s array and tabular environments the capability to draw horizontal/vertical dash-lines.

Contents

1 Introduction 2

2 Usage 2 2.1 Loading Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2 Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.3 Style Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.4 Fine Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.5 Finer Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.6 Performance Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Known Problems 5

∗This file has version number v1.4, last revised 2000/07/04.

1 Introduction

In January 1993, Weimin Zhang kindly posted a style hvdashln written by the author, which draws horizontal/vertical dash-lines in L^{A}TEX’s array and tabular environments, to the news group comp.text.tex. The style, unfortunately, has a known problem that vertical lines are broken when an array contains tall rows.

In March of the year, Monty Hayes complained of this problem encouraging the author to make a new version arydshln to solve the problem. The new style also has new features, such as allowing ‘:’ to specify vertical dash-line in preamble, and \cdashline being a counterpart of \cline.

In March 1999, Sebastian Rahtz kindly invited the style, which had been improved following the bug report from Takahiro Kubota, to be included in TEX CTAN and also in the online catalogue compiled by Graham Williams. This invitation gave the style new users including Peter Ehrbar who wished to use it with array style in Standard L^{A}TEX Tools Bundle and had trouble because these styles were incompatible with each other. Therefore, the style became compatible with array and now has additional new features.

2 Usage

2.1 Loading Package

The package is usable to both L^{A}TEX 2ε and L^{A}TEX-2.09 users with their standard package loading declaration. If you use L^{A}TEX 2ε, simply do the following.

     \usepackage{arydshln}

If you still love L^{A}TEX-2.09, the following is what you have to do.

     \documentstyle[..,arydshln,...]{⟨style⟩}

Only one caution given to users of array package included in Standard L^{A}TEX Tools Bundle is that arydshln has to be loaded after array done. That is, the following is correct but reversing the order of \usepackage will cause some mysterious error.

     \usepackage{array}
     \usepackage{arydshln}

2.2 Basic Usage

array You can simply use array or tabular(*) environments with standard preamble, such as

tabular  {r|c|ll}, and standard commands \\, \hline, \cline and \multicolumn.

Users of array package may also use all of newly introduced preamble characters, such as ‘>’, ‘<’, ‘m’, ‘b’, and all the commands such as \extrarowheight, \firsthilne and \lasthline. The preamble characters given by arydshln may be included in the second

argument of \newcolumntype.

: Drawing a vertical dash-line is quite simple. Use ‘:’ in the preamble as the separator of columns separated by the dash-line, just like using ‘|’ to draw a vertical solid-line.

The preamble means not only that of the environment, but also the first argument of

\multicolumn.

\hdashline It is also simple to draw a horizontal dash-line. Use \hdashline and \cdashline as

\cdashline the counterparts of \hline and \cline.

For example;

     \begin{tabular}{|l::c:r|}\hline
     A&B&C\\\hdashline
     AAA&BBB&CCC\\\cdashline{1-2}
     \multicolumn{2}{|l:}{AB}&C\\\hdashline\hdashline
     \end{tabular}

will produce the following result.

A  B  C
AAA BBB CCC
AB  C

\firsthdashline  If you use array, the dashed version of \firsthline and \lasthline named \first
\lasthdashline  hdashline and \lasthdashline are available.

2.3 Style Parameters

\dashlinedash You have two style parameters to control the shape of dash-lines: \dashlinedash is for the \dashlinegap length of each dash segment in a dash line; \dashlinegap controls the amount of each gap

between dash segments. Both parameters have a common default value, 4 pt.

2.4 Fine Tuning

; Although you can control the shape of dash-lines in an array/tabular environment as described in §2.3, you might want to draw a dash-line of a shape different from others. To specify the shape of a vertical dash-line explicitly, you may use;

;{⟨dash⟩/⟨gap⟩}

instead of ordinary ‘:’ and will have a dash-line with dash segments of ⟨dash⟩ long separated by spaces of ⟨gap⟩.

\hdashline As for horizontal dash-lines, explicit shape specifications may be given through optional

\cdashline arguments of \hdashline and \cdashline as follows.
     \hdashline[⟨dash⟩/⟨gap⟩]

\cdashline{⟨col1 ⟩-⟨col2 ⟩}[⟨dash⟩/⟨gap⟩]

For example;

     \begin{tabular}{|l::c;{2pt/2pt}r|}\hline
     A&B&C\\\hdashline[1pt/1pt]
     AAA&BBB&CCC\\\cdashline{1-2}[.4pt/1pt]
     \multicolumn{2}{|l;{2pt/2pt}}{AB}&C\\\hdashline\hdashline
     \end{tabular}

will produce the following result.

A  B  C
AAA BBB CCC
AB  C

\ADLnullwide The vertical solid and dashed lines are drawn as if their width is zero, as standard \ADLsomewide L^{A}TEX’s array and tabular do, if you don’t use array package. Otherwise, they have real

width of \arrayrulewidth as the authors of array prefers. However, you may explicitly tell arydshln to follow your own preference by \ADLnullwide if you love L^{A}TEX standard, or \ADLsomewide if you second the preference of array authors.

2.5 Finer Tuning

To draw dash-lines, we use a powerful primitive of TEX called \xleaders. It replicates a segment that consist of a dash and gap so that a dash-line has as many segments as possible and distributes remainder space to make the spaces between adjacent dash segments (almost) equal to each other. Therefore, you will have dash-lines with consistent steps of gaps and spaces as the left and upper lines in Figure 1(1) are.

However, because of a bug (or buggy feature) of \xleaders, there is a small possibility that a dash segment near the right/bottom end drops as right and lower lines in (1) of the figure shows. To cope with this problem, you may change the drawing mode by

\ADLdrawingmode{⟨m⟩} as follows.
\ADLdrawingmode  • m = 1

As shown in Figure 1(1), most beautiful in almost all cases as the left/upper lines, but has a small possibility to produce an ugly result as right/lower lines. This is default.

• m = 2 As shown in (2) of the figure, beautiful if dash-lines are not so sparse as right/lower lines, but dash segments near the both ends may be a little bit too long as left/upper lines.

• m = 3 As shown in (3) of the figure, beautiful if dash-lines are not so sparse as right/lower lines, but gaps near the both ends may be considerably too large as left/upper lines.

It is recommended to use default mode 1 unless you have an ugly result in the final version of your manuscript, because the correctness of mode 1 is very sensitive to the length of dash-lines,

A A A
B B B
C C C

A A A
B B B
C C C

A A A
B B B
C C C

Figure 1: Drawing mode controlled by \ADLdrawingmode

2.6 Performance Tuning

Since drawing dash-lines is a hard job, you have to be patient with the fact that the performance of typesetting array/tabular with dash-lines is poorer than that of ordinary ones. In fact, according to author’s small performance evaluation with a tabular having nine vertical and ten horizontal dash-lines, typesetting the tabular is approximately ten times as slow as its ordinary counterpart with solid lines.

However, this is not a really bad news, unfortunately. The real one is that loading arydshln makes typesetting array/tabular slower even if they only have solid lines which the package treats as special ones of dash-lines. The evaluation result shows the degradation factor is about nine. Therefore, if your document have many array/tabular with solid lines and quite few (or no) array/tabular with dash-lines, L^{A}TEX will run slowly.

\ADLinactivate To cope with this problem, you may inactivate dash-line functions by the command \ADLinactivate that replaces dash-lines with solid lines drawn by a faster (i.e. ordinary) mechanism. Although the inactivation does not completely solve the performance problem, the degradation factor will become much smaller and acceptable, approximately 1.5 in the author’s evaluation. For example, the draft version of your document will have the command in its preamble, which you will remove from your final version.

\ADLactivate Alternatively, you may do \ADLinactivate in the preamble, switch on by \ADLactivate before you really need dash-lines, and switch off again afterword. A wiser way could be

surrounding array/tabular by \begin{ADLactivate} and \end{ADLactivate}.

Array If you feel it tiresome to type the long command/environment name for the activation, Tabular you may use Array and Tabular(*) environment in which dash-line functions are always

active. Note that, however, since these environment names are too natural to keep them from being used by authors of other packages or yourself, name conflict could occur. If Array and/or Tabular have already been defined when arydshln is loaded, you will get a warning to show you have to define new environments, say dlarray and dltabular, as follows.

     \newenvironment{dlarray}{\ADLactivate\begin{array}}%
                             {\end{array}}
     \newenvironment{dltabular}{\ADLactivate\begin{tabular}}%
                               {\end{tabular}}
     \newenvironment{dltabular*}{\ADLactivate\begin{tabular*}}%
                                {\end{tabular*}}

\ADLnoshorthanded On the other hand, if they are defined after arydshln is loaded, their definitions are silently replaced or L^{A}TEX complains of multiple definitions. The error in the latter case

will be avoided by putting \ADLnoshorthanded just after \usepackage{arydshln}.

3 Known Problems

There are following known problems.

1. The new preamble specifiers ‘:’ and ‘;{⟨dash⟩/⟨gap⟩}’ cannot be followed or preceded by ‘@{⟨text⟩}’, or you will have an ugly result. More specifically, a specifier to draw a dash-line at the left edge of a column cannot be preceded by ‘@{⟨text⟩}’, while that to draw at the right edge cannot be followed by ‘@{⟨text⟩}’.

2. If you use array package, the restriction of ‘@’ shown above is also applied to ‘!’.

3. In order to make it sure that a dash-line always touches its both end, i.e. a dash-line always begins and ends with a dash segment, the amount of a gap will slightly vary depending on the dash-line length.

4. As described in §2.5, dash-lines drawn in the default mode 1 may lack a dash segment near its right/bottom end.

5. If a dash-line is too short, you will have an ugly result without overfull message. More specifically, in mode 1 or 3, a line will look to protrude beyond its column/row borders if it is shorter than a half of \dashlinedash. In mode 2, the minimum length to avoid

the protrusion is 1.5 × \dashlinedash + \dashlinegap.

6. As described in §2.6, the processing speed for array and tabular environment will become slower even if dash-lines are not included.

Acknowledgments

The author thanks to Monty Hayes who gave the author the opportunity to make this style, and Weimin Zhang and Takahiro Kubota who pointed out bugs in early versions. He also thanks to Sebastian Rahtz and Graham Williams who kindly invited the style to TEX CTAN and online catalogue compiled by Graham, and Peter Ehrbar who showed the style was incompatible with array and kindly accepted the offer to be an alpha-user of v1.4 alone.

The base implementation of array and tabular environments, part of which the author gives new definitions referring original ones, are written by Leslie Lamport as a part of L^{A}TEX-2.09 and L^{A}TEX 2ε (1997/12/01) to which Johannes Braams and other authors also contributed. The author also refers array package (v2.3m) written by Frank Mittelbach and David Carlisle to make the style compatible with array.

Index

:=:, 2 ;=;, 3

ADLactivate=  \subitem *+\ADLactivate+, \usage{5}
ADLdrawingmode=  \subitem *+\ADLdrawingmode+, \usage{4}
ADLinactivate=  \subitem *+\ADLinactivate+, \usage{5}
ADLnoshorthanded=  \subitem *+\ADLnoshorthanded+, \usage{5}
ADLnullwide=  \subitem *+\ADLnullwide+, \usage{4}
ADLsomewide=  \subitem *+\ADLsomewide+, \usage{4}

Array=Array  (environment),  5
array=array  (environment),  2

cdashline=  \subitem *+\cdashline+, \usage{3}

                                      dashlinedash=  \subitem *+\dashlinedash+, \usage{3}
                                      dashlinegap=  \subitem *+\dashlinegap+, \usage{3}
                                      documentstyle=  \subitem *+\documentstyle+, \usage{2}

environments:¿Array, 5 environments:¿array, 2 environments:¿Tabular, 5 environments:¿tabular, 2

                                      firsthdashline=  \subitem *+\firsthdashline+, \usage{3}
                                      hdashline=  \subitem *+\hdashline+, \usage{3}

lasthdashline=  \subitem *+\lasthdashline+, \usage{3}

Tabular=Tabular  (environment),  5

tabular=tabular  (environment),  2

                                           usepackage=  \subitem *+\usepackage+, \usage{2}