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.

My MWE is adapted from How to diagonally divide a table cell … properly?.

Two questions:

  1. I add an empiric rule of 0.71\baselineskip, but why 0.71?
  2. Why c=... is not centered as the text below is?

Edit One ca see a simplified and corrected version here : Optional argument problem

output

\documentclass[10pt,french]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{array}
\usepackage{calc}
\usepackage{tikz,fourier}

\newcommand\diag[5]{%
  \multicolumn{1}{|m{#2}|}{\hskip-\tabcolsep
  $\vcenter{\begin{tikzpicture}[baseline=0,anchor=south west,outer sep=0]
  \path[use as bounding box] (0,0) rectangle (#2+2\tabcolsep,\baselineskip);
  \node[minimum width={#2+2\tabcolsep-\pgflinewidth},
        minimum  height=\baselineskip+#3-\pgflinewidth] (box) {};
  \draw[line cap=round] (box.north west) -- (box.south east);
  \node[anchor=south west,align=left,inner sep=#1] at (box.south west) {#4};
  \node[anchor=north east,align=right,inner sep=#1] at (box.north east) {#5};
 \end{tikzpicture}}\rule{0pt}{.71\baselineskip+#3-\pgflinewidth}$\hskip-\tabcolsep}}

\begin{document}
\begin{tabular}{%
    |>{\centering\arraybackslash}m{4.5cm}
    |*{4}{>{\centering\arraybackslash}m{2.5em}|}}\hline
\diag{\tabcolsep}{4.5cm}{3.4em}{Coefficient\\ de frottement $c$}{Vitesse $V$\\ (en km/h)}&50&90&110&20\\ \hline
$c=0,8$\newline route s\`eche, bitume neuf &&&&\\ \hline
$c=0,7$\newline route s\`eche, bitume moyen &&&&\\ \hline
$c=0,8$\newline route mouill\'ee, bitume moyen &&&&\\ \hline
\end{tabular}
\end{document}
share|improve this question
    
Could 0.71 be an approximation to 1/\sqrt{2}=0.70710678...? –  Mico May 5 at 11:43
    
@Mico As \strut definition is \rule[-.3\baselineskip]{0pt}{\baselineskip}, I thaught it came from hidden \strut ... –  Tarass May 5 at 16:02

1 Answer 1

up vote 3 down vote accepted

A solution with package diagbox:

\documentclass[10pt,french]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{array}
\usepackage{diagbox,ragged2e}
\usepackage{fourier}

\begin{document}
\begin{tabular}{%
    |>{\Centering}m{4.5cm}
    |*{4}{>{\Centering}m{2.5em}|}}\hline
\diagbox{\shortstack{Coefficient de\\ frottement $c$}}
        {\shortstack{\vphantom{Ä}Vitesse $V$\\(en km/h)}} & 50 & 90 & 110 & 20 \\ \hline
$c=0,8$\newline route s\`eche, bitume neuf &&&&\\ \hline
$c=0,7$\newline route s\`eche, bitume moyen &&&&\\ \hline
$c=0,8$\newline route mouill\'ee, bitume moyen &&&&\\ \hline
\end{tabular}

\end{document}

enter image description here

Use \diag{\tabcolsep}{4.5cm}{0em}.... and in the \diagmacro set \rule{4pt}{0.71\baselineskip....} then you'll see that it is the height of the current line (without a the depth). The entried are left and right aligned, see the optional arguments of \node: align=.... Change it to align=center and it will no more be left/right aligned.

share|improve this answer
    
@Herbet Thank you for your usefull answer, I learned of it. I still want to know the two points asked above. –  Tarass May 5 at 15:56
    
see my edited answer –  Herbert May 6 at 6:40
    
For the depth I agree with you, but for align=... it is not work. I speak about c=... in lines 2 to 4, there's no nodes here. –  Tarass May 6 at 7:57
    
Ah I see, a misunderstanding. Load package ragged2e and then \Centering, as seen in my example. –  Herbert May 6 at 7:58

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.