0

I want to plot the below figure. What must I do in Latex.enter image description here

Thruston
  • 42,268
Nima
  • 139

2 Answers2

3

Here is a short solution with pstricks. Loading auto-pst-pdf, you can compile with pdflatex, if you use the --enable-write18' switch for MiKTeX,shell-escapefor TeX Live or MacTeX. Alternatively you can compile directly withxelatex`:

\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%
\usepackage{lmodern}

\usepackage[x11names]{pstricks}%, pdf[]
\usepackage{pst-poly}
\usepackage{auto-pst-pdf} % for pdflatex

 \pagestyle{empty}
\begin{document}

   \begin{pspicture}%
        \psset{unit=1.5cm, linewidth=0.6pt, arrows=c, shortput=nab, linejoin=1}
        \rput(0,0){\PstSquare[PolyName=A]}
        \rput(2,0){\PstSquare[PolyName=B]}
        \psset{fillstyle=solid, fillcolor=Grey0!60!}
        \pspolygon(A2)(A3)(A4)
        \pspolygon(B2)(B1)(B4)
        \psset{linestyle=solid, labelsep=2.5ex}
        \ncline{A2}{A4}_{$ L $}
        \ncline{B4}{B2}_{$ U $}
    \end{pspicture}

\end{document} 

enter image description here

Bernard
  • 271,350
3

TikZ requires no special treatment; this gives squares with a 2cm side.

\documentclass{article}
\usepackage{tikz,xcolor}

\begin{document}

\begin{tikzpicture}
\fill[black!30] (0,0)--(0,2)--(2,0)--cycle ; % the filled triangle
\draw (0,0)--(0,2)--(2,2)--(2,0)--cycle ;    % the square
\draw (0,2)--(2,0) ;                         % the diagonal
\node at (0.5,0.5) {$L$} ;                   % the label
\end{tikzpicture}\quad
\begin{tikzpicture}
\fill[black!30] (2,2)--(0,2)--(2,0)--cycle ;
\draw (0,0)--(0,2)--(2,2)--(2,0)--cycle ;
\draw (0,2)--(2,0) ;
\node at (1.5,1.5) {$U$} ;
\end{tikzpicture}

\end{document}

enter image description here

egreg
  • 1,121,712