1

I have this image that I want to add in my latex file: enter image description here

Here is my MWE:

\usepackage{graphicx}

\usepackage{amssymb,amsthm}

\usepackage{natbib}

\bibpunct{(}{)}{;}{;}{,}{,}

\usepackage{xr-hyper}

\usepackage[
  colorlinks=true,
  citecolor=blue,
  urlcolor=blue,
  linkcolor=blue
]{hyperref}

\usepackage{bm}

\usepackage{fullpage}

\usepackage{ amssymb }

    \pagestyle{plain}

\setlength{\parskip}{\baselineskip}
\setlength{\parindent}{0pt}

\setcounter{secnumdepth}{2}

\allowdisplaybreaks[4]

% Commenting/debugging
\let\IG\iffalse
\let\ENDIG\fi

%% Shortcuts
\newcommand{\td}[2]{\dfrac{d #1}{d #2}}
\newcommand{\std}[2]{\dfrac{d^2 #1}{d {#2}^2}}
\newcommand{\ctd}[3]{\dfrac{d^2 #1}{d #2 d #3}}

\newcommand{\pd}[2]{\dfrac{\partial #1}{\partial #2}}
\newcommand{\spd}[2]{\dfrac{\partial^2 #1}{\partial {#2}^2}}
\newcommand{\cpd}[3]{\dfrac{\partial^2 #1}{\partial #2 \partial #3}}

\newcommand{\pdi}[2]{\partial #1/\partial #2}

\newcommand{\LR}{\Leftrightarrow}
\newcommand{\Lg}{\mathcal{L}}
\newcommand{\half}{\tfrac{1}{2}}
\newcommand{\eqp}{\phantom{=}}
\newcommand{\eqs}{\buildrel s \over =}

\begin{document}
\end{document}

I also want to label the figure.

OGC
  • 809
  • 2
    You should use the \includegraphics[options]{file.ext} for insert that, but with the following structure: \begin{figure}[htbp] \begin{center} \includegraphics[options]{file.ext} \end{center} \caption[Short caption if needed]{Caption here} \label{fig:figurename} \end{figure}. Please read How to import graphics for understand it better. – Aradnix Sep 29 '14 at 05:24
  • 4
    @Aradnix Generally it's best to leave out the extension of the graphics file, and use \centering instead of the center environment (Should I use center or centering for figures and tables?)). – Torbjørn T. Sep 29 '14 at 06:23
  • 1
    @Aradnix: One should use \centering rather than the center environment, which adds spurious vertical spacing. – Bernard Sep 29 '14 at 08:13
  • 2
    Why is this downvoted? What else do you need self-solving question? – percusse Sep 29 '14 at 13:48
  • @percusse It is downvoted, because imho @user36829 did not even try to resolve it by him/herself, see the rules. The \includegraphics command is the very basic one -- so this was the main reason. Another minor reason is that the source code provided is useless for resolving this kind of question, because there are only listed packages and newcommands. – Václav Pavlík Sep 29 '14 at 15:47
  • @VáclavPavlík I don't want to get into that rules debate. We don't have any rules here. See meta.TeX.SE for a lot of related discussion. Research required is a SO thing. We don't have it here. In summary, SO habits don't apply. We only have guidelines. – percusse Sep 29 '14 at 16:12
  • @percusse I do not want to have any dispute either and this is certainly not the place to have it. I think it is clear why I voted down and I can support it by many arguments. So please let me have my opinion. – Václav Pavlík Sep 29 '14 at 16:28
  • @VáclavPavlík Bring it up in chat you'll be informed better by others too. It's not just your opinion but a community etiquette. – percusse Sep 29 '14 at 16:37
  • @TorbjørnT. You're right, it was my mistake to copy and paste without changing the snippet of Sublime Text 2 I used. – Aradnix Sep 30 '14 at 02:49
  • @Bernard It's true but many snippets that are used to compose figures and even some books recommend using the center environment, I use centering when I have many figures in a document, I understand that consumes less memory. – Aradnix Sep 30 '14 at 02:52
  • @ Aradnix: I see. Didn't know that. – Bernard Sep 30 '14 at 07:59

1 Answers1

6

Add \usepackage{tikz} to your preamble.

Then where you want your figure insert the following code.

\begin{figure}
\begin{tikzpicture}
%axis
\draw (12,0) -- (0,0)--(0,10);
% Blue lines
\draw[blue] (0,9)node[left]{\color{black}20} -- (11,0)node[below]{\color{   black}12}node[near end,right]{\color{black}$MC_2$};
\draw[blue] (0,9) -- (9,0)node[below]{\color{black}10}node[near end,left]{  \color{black}$MC_1$};
% Red lines
\draw[red] (0,1) -- (5,10)node[near end,right]{\color{black}$MB_1$};
\draw[red] (0,0.5) -- (8,10)node[near end,right]{\color{black}$MB_2$};
% Dotted lines
\draw[dotted,thick] (2.85,0)node[below]{$I^*$} -- (2.85,6.1)--(0,6.1)node[  left]{$U(I^*)$};
\draw[dotted,thick] (4.25,0)node[below]{$I$} -- (4.25,5.53)--(0,5.53)node[  left]{$U(I)$};
\draw (0,0)node[below]{0}node[left]{0};
\end{tikzpicture}
%Figure caption
\caption{Demo of TikZ Figure}
\end{figure}

To produce the graf below

Graf

Rud Faden
  • 2,124
  • 1
  • 17
  • 11