[Tex/LaTex] problem packages diagbox and cancel

canceldiagbox

When using cancel package to cross out something and the package diagbox is also loaded the line does not appear in the proper location. When diagbox is not loaded everything works ok. However, I need to load that package to use it with some cells in tables.

See the following MWE:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{diagbox} 
\usepackage{cancel}
\begin{document}
Some text $\frac{ \cancel{2} \cdot \cancel{ \left( q_{1}+2 \right) } }{p_1}$
\end{document}

Best Answer

The diagbox package internally loads pict2e which does some redefinitions that cause the problem with cancel; to prevent the redefinitions made by pict2e, load the pict2e package with the original option before diagbox:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage[original]{pict2e}
\usepackage{diagbox} 
\usepackage{cancel}
\begin{document}
Some text $\frac{ \cancel{2} \cdot \cancel{ \left( q_{1}+2 \right) } }{p_1}$
\end{document}

enter image description here

Another possibility is to pass the original option as class option, so pict2e will pick it up:

\documentclass[12pt,a4paper,original]{article}
\usepackage{amsmath}
\usepackage{diagbox} 
\usepackage{cancel}
\begin{document}
Some text $\frac{ \cancel{2} \cdot \cancel{ \left( q_{1}+2 \right) } }{p_1}$
\end{document}
Related Question