Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following code:

\documentclass{article}
\usepackage{amssymb}
\usepackage{caption,sansmath}
\usepackage{array}
\DeclareCaptionFont{sansmath}{\sansmath}
\captionsetup{textfont={sf,sansmath}}

\newlength\Origarrayrulewidth

% horizontal rule equivalent to \cline but with 2pt width
\newcommand{\Cline}[1]{%
 \noalign{\global\setlength\Origarrayrulewidth{\arrayrulewidth}}%
 \noalign{\global\setlength\arrayrulewidth{2pt}}\cline{#1}%
 \noalign{\global\setlength\arrayrulewidth{\Origarrayrulewidth}}%
}

% draw a vertical rule of width 2pt on both sides of a cell
\newcommand\Thickvrule[1]{%
  \multicolumn{1}{!{\vrule width 2pt}c!{\vrule width 2pt}}{#1}%
}

% draw a vertical rule of width 2pt on the left side of a cell
\newcommand\Thickvrulel[1]{%
  \multicolumn{1}{!{\vrule width 2pt}c|}{#1}%
}

% draw a vertical rule of width 2pt on the right side of a cell
\newcommand\Thickvruler[1]{%
  \multicolumn{1}{|c!{\vrule width 2pt}}{#1}%
}

% Square cells in the matrix, so we just increase the space between rows
\renewcommand{\arraystretch}{1.5}

\begin{document}

\begin{table}
\parbox{.45\linewidth}{
\centering
        \begin{tabular}{ c |c|c|c|c|c|}
            \multicolumn{1}{c}{~} & \multicolumn{1}{c}{$c_{1}$} & \multicolumn{1}{c}{$c_{2}$} & \multicolumn{1}{c}{$c_{3}$} & \multicolumn{1}{c}{$c_{4}$} & \multicolumn{1}{c}{$c_{5}$} \\ \cline{2-6}
            $r_{1}$ & 2     & 8     & 4     & 5     & 3     \\ \cline{2-6}
            $r_{2}$ & 4       & 9     & 6     & 7     & 1     \\ \cline{2-6}
            $r_{3}$ & 3       & 4     & 2     & 0     & 9     \\ \cline{2-6}
            $r_{4}$ & 1       & 0     & 9     & 8     & 4     \\ \cline{2-6}
            $r_{5}$ & 8       & 3     & 7     & 6     & 5     \\ \cline{2-6}
        \end{tabular}
        \caption{}
    }
    \hfill
\parbox{.45\linewidth}{
\centering
        \begin{tabular}{ c |c|c|c|c|c|}
           \multicolumn{1}{c}{~} & \multicolumn{1}{c}{1} & \multicolumn{1}{c}{2} & \multicolumn{1}{c}{3} & \multicolumn{1}{c}{4} & \multicolumn{1}{c}{5} \\ \Cline{2-2}\cline{2-6}
           1 & \Thickvrule{\hspace{0.8em}}       & \hspace{0.8em}     & \hspace{0.8em}     & \hspace{0.8em}     & \hspace{0.8em}     \\ \Cline{2-3}\cline{3-6}
           2 &  \hspace{0.8em}  & \Thickvrule{~}    & \hspace{0.8em}    & \hspace{0.8em}     &\hspace{0.8em}     \\ \cline{2-3}\Cline{3-4}\cline{4-6}
           3 & \hspace{0.8em}       & \hspace{0.8em}     & \Thickvrule{\hspace{0.8em}}     & \hspace{0.8em}     & \hspace{0.8em}     \\ \cline{2-4}\Cline{4-5}\cline{6-6}
           4 & \hspace{0.8em}       & \hspace{0.8em}    & \hspace{0.8em}     & \Thickvrule{\hspace{0.8em}}     & \hspace{0.8em}     \\ \cline{2-5}\Cline{5-6}
           5 & \hspace{0.8em}      & \hspace{0.8em}     & \hspace{0.8em}    & \hspace{0.8em}     & \Thickvrule{\hspace{0.8em}}     \\ \cline{2-6}\Cline{6-6}
        \end{tabular}
        \caption{}
}
\end{table}

\end{document} 

This code was copied from here:

Change border of a few cells in a table

The code is correct. When I am trying to use the pdfpages package, the thick horizontal line is not shown. Could you please answer what is the reason? When I remove this package, the line is shown successfully. I have a lot of matrices in the article, I can't remove them or rewrite, but also I must add an appendix at the end of the document.

After redefining \setlength I have the error:

! Missing number, treated as zero.
<to be read again> 
                   (
l.1584 \includepdf[pages=-]{nosingl1.pdf}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Illegal unit of measure (pt inserted).
<to be read again> 
                   (
l.1584 \includepdf[pages=-]{nosingl1.pdf}

Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)

If I don't redefine it, the code is compiled successfully, that is the compilation error occurs when I am including a pdf file:

\includepdf[pages=-]{nosingl1.pdf}
\includepdf[angle=90]{nosingl2.pdf}
\includepdf[angle=90]{nosingl3.pdf}
share|improve this question
    
Your statement, "When I'm trying to use the pdfpages package, ..." is ambiguous: Are you trying to include the output of the current MWE in some other file and that's when the problem occurs, or does the mere loading of the pdfpages document in the current document cause the problem behavior? Please elaborate. –  Mico Jun 24 '12 at 18:14
    
I just declare \usepackage{pdfpages} and want to include some pdf files: \includepdf{1.pdf}. The line is not shown, even when I don't try to include smth, just declare this package. –  user565447 Jun 24 '12 at 18:56
    
It's a (bad?) side effect of texpower package which is required by pdfpages package. Just add \usepackage{texpower} and you get the same effect (\Cline don't produce thick rule). –  Paul Gaborit Jun 24 '12 at 20:25
    
@PolGab: pdfpages doesn't load texpower... well, not in version 2012/04/03 v0.4s. –  Werner Jun 24 '12 at 20:47
    
@Werner Exact... It's a (bad?) side effect of calc package which is required by pdfpages package. Just add \usepackage{calc} and you get the same effect (\Cline don't produce thick rule). calc redefines \setlength. –  Paul Gaborit Jun 24 '12 at 21:05

2 Answers 2

Using the TeX-style length settings seems to circumvent the problem, otherwise the length settings remain local:

enter image description here

% horizontal rule equivalent to \cline but with 2pt width
\newcommand{\Cline}[1]{%
  \noalign{\global\Origarrayrulewidth\arrayrulewidth%
    \global\arrayrulewidth2pt}\cline{#1}%
  \noalign{\global\arrayrulewidth\Origarrayrulewidth}%
}

As mentioned by PolGab in comment, this interaction results from calc (loaded by pdfpages) redefining \setlength. Restoring the original \setlength command (after loading pdfpages or calc) to

\def\setlength#1#2{#1#2\relax}%

also solves this problem. Not sure about other side-effects though.

share|improve this answer
    
Is there an error in your code? After your redefining I have the error. See the updated question –  user565447 Jun 25 '12 at 4:44
    
@user565447: Have you tried the version of \Cline in my answer rather than a redefinition of \setlength? –  Werner Jun 25 '12 at 5:14
    
yes, I have. There is no result –  user565447 Jun 25 '12 at 5:46
    
See the updated question –  user565447 Jun 25 '12 at 6:40

The problem is mainly that

\global\setlength

is not officially supported by LaTeX and, in fact, calc redefines setlength in a way that makes \global\setlength completely ineffective, as it applies \global to a temporary variable (precisely it does \global\let\calc@A #1, where #1 is the argument to \setlength).

Simply write

\newcommand{\Cline}[1]{%
 \noalign{\xdef\Origarrayrulewidth{\the\arrayrulewidth}}%
 \noalign{\global\arrayrulewidth=2pt}\cline{#1}%
 \noalign{\global\arrayrulewidth=\Origarrayrulewidth}%
}

which also avoids allocating \Origarrayrulewidth as dimension.

Redefining \setlength after having loaded pdfpages is of course not recommendable, as this package does rely on \setlength as defined by calc.

share|improve this answer
    
it doesn't help. I have the compilation error –  user565447 Jun 27 '12 at 19:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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