[Tex/LaTex] Diagram with a shaded region

shadingtikz-pgf

enter image description here

The following MWE yields the diagram above but I would like to find a better way of showing the shaded region.

\documentclass[letterpaper]{article}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
    \begin{tikzpicture}
        \draw[fill=black!20!white] (0,2)--(2,0)--(3,0)--(3,2)--cycle;
        \draw (0,0) --node[below] {$2x$}(2,0)--node[below] {$\vphantom{2}x$}(3,0)--(3,2)--(0,2)-- node[left] {$x-7$}cycle;
    \end{tikzpicture}
\end{document}

Note that the top left corner does not look pretty. Am thinking about clipping but seems a bit too much.

Best Answer

You can exploit the path picture key of the nodes:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\usepackage{amsmath}
\begin{document}
    \begin{tikzpicture}
    \draw[fill=black!20!white] (0,2)--(2,0)--(3,0)--(3,2)--cycle;
    \draw (0,0) --node[below] {$2x$}(2,0)--node[below] {$\vphantom{2}x$}(3,0)--(3,2)--(0,2)-- node[left] {$x-7$}cycle;
    \end{tikzpicture}

    \begin{tikzpicture}
    \node[rectangle, minimum width=3cm, minimum height=2cm, inner sep=0pt, fill=white,draw, path picture={%
        \fill[black!20]($(path picture bounding box.south)!.35!(path picture bounding box.south east)$) coordinate(a)--
        (path picture bounding box.north west)--
        (path picture bounding box.north east)|-
        (path picture bounding box.south); % filling
        \draw (a)--(path picture bounding box.north west);% line
    }] (x) at (0,0){};
    \node[left=2pt] at (x.west){$x-7$};
    \node[below] at ($(x.south)!.35!(x.south west)$){$2x$};
    \node[below] at ($(x.south)!.65!(x.south east)$){$\vphantom{2}x$};
\end{tikzpicture}
\end{document}

The result:

enter image description here