2

I've created a plot using matplotlib in Python and saved it to a PGF which I've then embedded in my LaTeX document. I'd like it to be a bit smaller, as is it won't centre and it forces down a section's header which is supposed to be above it.

Here's the link for the pgf file http://www.fast-files.com/getfile.aspx?file=191033

\documentclass[12pt]{article}

\title{COMP 2823: Assignment 1}
\author{Student ID: 480380498}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage{ulem}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{compat=1.16}

\pagestyle{fancy}
\fancyhf{}
\rhead{SID: 480380498}

\begin{document}
...

\newpage
\section{}
Text \\
\begin{figure}
\begin{center}
\input{graph1.pgf}
\end{center}
\end{figure}
\end{document}

enter image description here

1 Answers1

2

Try with:

\documentclass[12pt]{article}

\title{COMP 2823: Assignment 1}
\author{Student ID: 480380498}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage{ulem}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{compat=1.16}

\pagestyle{fancy}
\fancyhf{}
\rhead{SID: 480380498}

\begin{document}
    ...

    \newpage% why a newpage?
    \section{without title?}
    Text % don't use \\, leave a blank line to create a new paragraph   

    \begin{center}
        \resizebox{\linewidth}{!}{\input{graph1.pgf}}
    \end{center}
\end{document}

(Not tested because I don't have a .pgf file).

And see also: When should we use \begin{center} instead of \centering?

CarLaTeX
  • 62,716
  • This does the job of resizing the img, but it still displaces the section header. Also I just wanted to put the next section of the document on a new page, no real reason. P.s. I tried to vote for your answer but my rep's too low :( – Marvin GaTeX Mar 02 '19 at 08:40
  • 1
    @MarvinGaTeX If you don't want the figure floating (that is, going around where LaTeX puts it), just use center instead of figure. See my renewed code. – CarLaTeX Mar 02 '19 at 08:49