Search In This Website

Kamis, 09 Oktober 2025

Program Linear Graph In Latex 1

1. type this in Latex editor

% !TEX TS-program = pdflatex

%Typeset/Build program

\documentclass[preview=true,multi,crop=false,tikz]{standalone}


%% 5.3 Macros and environments

\standaloneconfig{border=10}

\standaloneenv{minipage,tikzpicture}


%% hatch line between, shaded line bounded between


\usepackage{amsmath}

\usepackage{pgfplots}

\pgfplotsset{compat=1.18}

\usetikzlibrary{decorations.markings}


\tikzset{

region2/.style={

 postaction={decorate},

 decoration={

   markings,

   mark=between positions 0 and 1 step 0.75mm with { %

     % note that the values are in axis units

     \draw [solid,thin] (axis direction cs:0,#1*0.1) -- (axis direction cs:0,#1*1);

   }

 },

 /pgfplots/forget plot

},

region/.default=1

}


\begin{document}


\begin{minipage}[t]{0.55\linewidth}

  $\displaystyle\begin{cases}

    ax + 4y \\

    x + y = 12 \\

    x + 2y = 16 \\

  \end{cases}$

\end{minipage}


\begin{tikzpicture} %% 2

  \begin{axis}[ %

      axis x line=center,  axis y line=center,

      width=4in, height=4in,

      x axis line style={<->},

      y axis line style={<->},

      xmin=-1,   xmax=16,

      ymin=0,   ymax=12,

      every axis plot/.append style={

         very thick,

         cyan!50!black,

         domain=-10:16,

         samples=2, % all you need for straight lines

      } %, nodes near coords

    ]

    \addplot [solid,black] {12 - x};

    \addplot [black]{8 - 0.5*x};

    

% path/hatch/parallel segments to be decorated between two intersection lines

    \addplot [region2] coordinates{(0,12)(8,4)(16,0)};

    

    \addplot [dashed,black] coordinates {(0,4)(8,4)};

    \addplot [dashed,black] coordinates {(8,0)(8,4)};

    

  \end{axis}

\end{tikzpicture} %% end 2

\end{document}

2. Compile or build

3. Output similar like below


Notes 

  • To see the more clear screenshot, click on the picture.
  • Maybe you need a little bit high computer requirement to learn from above lesson list.

Tidak ada komentar:

Posting Komentar