[texhax] diagonal in a table

Joel Coltoff joel at wmi.com
Wed Jun 25 10:32:14 CEST 2003


On Wed, 25 Jun 2003, Sergei Duzhin wrote:

> Is there anybody who knows a nice way to typeset the diagonal line in the
> upper left cell of a table like this:
>
>  --------------------------
>  |\ k |    |    |
>  | \  |  1 |  2 |
>  |n \ |    |    |
>  ----------------
>  |    |    |    |
>  | 1  |    |    |
>  |    |    |    |
>  ----------------
>  |    |    |
>  | 2  |    |
>  |    |    |
>  --------------   ?
>
> I would appreciate any advice by e-mail.

Here's some stuff from comp.text.tex (from as far back as 1994) that I saved
but have never used. I just tried them and they do work. You may be able to
adapt one of these to your needs.


-------------------------
\documentclass{report}
\def\K{\kern.25em}
\newdimen\diaght
\def\Ln{%
  \ifdim \diaght<-6pt
    \let\Ln=\relax
  \else \advance\diaght by-.3pt
    \raise \diaght \hbox{\vrule height .3pt depth .3pt width .3pt}%
  \fi \Ln}
\begin{document}

\begin{tabular}{cc}
V & V  \\
\vline\K\llap{x} & \llap{\diaght=10pt \Ln}\vline \\
$\alpha$ & $\beta$
\end{tabular}

\begin{tabular}{cc}
{[P of A]} & [P of A] \\
\vline\K\llap{x} & \vline \\
C & C
\end{tabular}

\end{document}
-------------------------



-------------------------
\documentclass{report}
\begin{document}

\begin{center}
  \begin{tabular}{|c|c|c|} \hline
    & & \\ [-2mm]
    \begin{picture}(70,70)(0,0)
      \put(0,0){\framebox(70,70){\ }}
      \put(20,55){\bf Across}
      \put(0,70){\line(1,-1){70}}
      \put(5,5){\bf Down}
    \end{picture}
              & \bf Col Head 1 & \bf Col Head 2 \\ \hline
    \bf Row 1 & Item C1,R1     & Item C2,R1 \\
    \bf Row 2 & Item C1,R2     & Item C2,R2 \\
    \bf Row 3 & Item C1,R3     & Item C2,R3 \\ \hline
  \end{tabular}

\end{center}

\noindent
Usually, in \LaTeX , this sort of general column heading is handled
through the use of the "{\tt multicolumn}" command to span several columns:
\begin{verbatim}
    \multicolumn{#1}{#2}{#3}
\end{verbatim}
where: `\verb+#1+' is the number of columns to span,
       `\verb+#2+' is the format for the new column, and
       `\verb+#3+' is the text for the new column.
For example:
\begin{center}
  \begin{tabular}{|c|c|c|} \hline
              & \multicolumn{2}{|c|}{\bf Across} \\ \cline{2-3}
    {\bf Down}& \bf Col Head 1 & \bf Col Head 2 \\ \hline
    \bf Row 1 & Item C1,R1     & Item C2,R1 \\
    \bf Row 2 & Item C1,R2     & Item C2,R2 \\
    \bf Row 3 & Item C1,R3     & Item C2,R3 \\ \hline
  \end{tabular}

\end{center}

\end{document}
-------------------------


-- 
Joel Coltoff

In theory, there is no difference between theory and practice.
But, in practice, there is.
    -- Jan L.A. van de Snepscheut



More information about the texhax mailing list