from mpltools import style # found this online at git@github.com:tonysyu/mpltools.git ## You can just leave the lines above and below out to get to the quick fix. style.use(['ggplot', 'pof']) #uses ggplot style. x = arange(-pi,pi,0.1) y1 = (sin((x*5))/10.0)+0.5 y2 = (sin(x**2)) figsize(10,5) plot(x,y1,linewidth=2) plot(x,y2,linewidth=2) title('Some title \n',fontsize=20) ylabel('y-label',fontsize=16) xlabel('x-label',fontsize=16) savefig('figure.png') #save the figure in the appropriate folder and write a section of latex code to insert it into the final document. %%writefile ref.bib @Article{PER-GRA_2007, Author = {Perez, Fernando and Granger, Brian E.}, Title = {{IP}ython: a {S}ystem for {I}nteractive {S}cientific {C}omputing}, Journal = {{C}omput. {S}ci. {E}ng.}, Volume = {9}, Number = {3}, Pages = {21-29}, month = may, year = 2007, url = "http://ipython.org", } %%writefile section2.tex %This is the section that contains the image. \subsection{Part2} This is the second section of your new \LaTeX document. We also plot the graphs of $\frac{sin(5x)}{10}+0.5$ and $sin(x^2)$ for no reason. \begin{figure}[H] \centering \includegraphics[width = \textwidth]{figure.png} \caption{\emph{Here is your figure, all neat in \LaTeX.}} \end{figure} %%writefile abstract.tex \begin{abstract} This is the poor man's solution to integrating all of your shit into one dynamic document. \end{abstract} %%writefile test2.tex \documentclass[a4paper,11pt]{article} %This is the standard Latex article template \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{graphicx} % This is for the image, not sure if it is required, but its there none the less \usepackage{float} % This is for placing the image at a specific location \usepackage[left=1.2cm,right=1.2cm,top=0cm,bottom=0cm]{geometry} \title{\LaTeX from Ipython notebooks} \author{PA Marais} \begin{document} \maketitle \input{abstract} \input{section1} \input{section2} \nocite{PER-GRA_2007} \bibliographystyle{unsrt} \bibliography{ref} \end{document} %%bash #use pandoc to convert section one to tex code from markdown pandoc -f markdown -t latex section1.txt -o section1.tex #run the standard bibtex and pdflatex commands to generate your final pdf bibtex test2 pdflatex test2.tex xdg-open test2.pdf