Skip to content

Instantly share code, notes, and snippets.

@user202729
Created March 5, 2024 22:51
Show Gist options
  • Save user202729/cbd890483154fb46f99f1e81bd9c5837 to your computer and use it in GitHub Desktop.
Save user202729/cbd890483154fb46f99f1e81bd9c5837 to your computer and use it in GitHub Desktop.
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{array}
\usepackage{makecell}
\newcolumntype{x}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{tikz}
\begin{document}
\newcommand\diag[4]{%
\multicolumn{1}{@{}p{#2}@{}|}{%
\hsize=\dimexpr#2+2\tabcolsep\relax
$\vcenter{\begin{tikzpicture}[baseline=0,anchor=south west,inner sep=#1]
\path[use as bounding box] (0,0) rectangle (#2+2\tabcolsep,\baselineskip);
\node[minimum width={#2+2\tabcolsep-\pgflinewidth},
minimum height=\baselineskip+\extrarowheight-\pgflinewidth] (box) {};
\draw[line cap=round] (box.north west) -- (box.south east);
\node[anchor=south west] at (box.south west) {#3};
\node[anchor=north east] at (box.north east) {#4};
\end{tikzpicture}}$}}
\setlength{\extrarowheight}{0.1cm}
\begin{tabular}{|x{0.5cm}|x{0.5cm}|x{0.5cm}|x{0.5cm}|x{0.5cm}|}\hline
&&&&20\\ \hline
&&&&30\\ \hline
&&&&45\\ \hline
?5&12&18&50&\diag{.1em}{0.5cm}{$a_i$}{$b_j$}\\ \hline
\end{tabular}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment