0

I have two graphs that I want to put side by side in Latex. At the moment they can only be displayed one underneath the other. Both are in the format:

\documentclass[11pt,a4paper]{article}

\usepackage[sort]{natbib}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{amsmath,amsfonts,amsthm,nicefrac,latexsym,amsfonts,amsbsy,bm}
\usepackage[nottoc,numbib]{tocbibind}

\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{mwe}

\begin{document}

\begin{tikzpicture}[xscale=0.8,yscale=2,domain=0.5:7]

% Axes

\draw[thick,->] (-.5,0) -- (10,0) node[right] {x};

\draw[thick,->] (0,-0.1) -- (0,2.5) node[right] {f(x)};

% Curve

\draw[color=white] (4.6,2.2) node[above,black]{\Large {Backward Difference}};

\draw[thick,color=black,domain=1.25:9,smooth,variable=\x] plot ({10-\x},{-ln(\x)+2.5});

\draw[very thick,color=red] (3,0.555)--(4.640957,0.825) node[above left,black]{Approximation};

\draw[very thick,color=blue,domain=3.5:8.52,smooth,variable=\x] plot (\x,{0.81 + 0.2*(\x-4.640957) ) }) node[below right,black] {Actual Derivative};

% Points

\foreach \point in {(3,0.555),(4.640957,0.825)}{% points \fill \point circle (1.5pt);}

% Axis labels

\foreach \x/\xtext in {3/{x_{i-1}},4.640957/{x_i},7/{x_{i+1}}} \draw(\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] {\xtext};

\end{tikzpicture}

\end{document}
5
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – dexteritas Feb 25 at 12:42
  • 1
    If you just wand two separate images side by side have a look at Two figures side by side. – dexteritas Feb 25 at 12:43
  • I apologise, it's a long document previous to this. I've edited the question – Mol Feb 25 at 12:57
  • @Mol does this code compile – js bibra Feb 26 at 0:45
  • Yes, the graphs come out how I want them to. I just can’t put it side by side – Mol Feb 27 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.