I try to adapt this solution How to diagonally divide a table cell … properly? to my needs.
But I have a width problem 1\tabcolsep
is too short, but anything longer is too long, should be 2\tabcolsep
.
\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{array}
\usepackage{tabularx}
\usepackage{ragged2e}
\newcolumntype{C}[1]{>{\Centering}p{#1}}
\usepackage{tikz}
\newcommand\Tdiag[4]{%
\multicolumn{1}{|p{#2}|}{\hskip-\tabcolsep
\begin{tikzpicture}[%
baseline={(0,-.25\baselineskip)},
every node/.style={outer sep=0pt,inner sep=#1}]
\node[minimum width={#2+1\tabcolsep-\pgflinewidth},
minimum height=2\baselineskip-\pgflinewidth+\extrarowheight,
use as bounding box] (box) {};
\draw[line cap=round] (box.north west) -- (box.south east);
\node[anchor=south west,text width=.75*#2,align=left] at (box.south west) {#3};
\node[anchor=north east,text width=.75*#2,align=right] at (box.north east) {#4};
\end{tikzpicture}\hskip-\tabcolsep}}
\begin{document}
\begin{tabular}{|C{1.2cm}*{3}{|c}|}\hline
\Tdiag{.2em}{1.2cm}{\^Age}{Sexe}&
Féminin & Masculin & Totaux \\\hline
15 ans&&1&\\\hline
16 ans & 16 & & \\\hline
17 ans & 3 & & \\\hline
Totaux & & & 36 \\\hline
\end{tabular}
\end{document}
;-)