1

I'm writing up my bachelors thesis. I have used the appendix{} command i.e.,

      \newpage\chead{Appendix}\begin{appendices}\numberwithin{equation}{section}

and I have a lot of sections in the appendix. The section where I reference mathematical concepts is no problem as I'm just writing and adding equations and defintions. I do have a section where I add PDF files of MATLAB code I generated for the paper. When I add the boxed in PDF figure, its not where it should be. This is the code:

\newpage\rhead{Matlab Code}\section{Matlab Code}\label{sec:MatlabCode}

% Appendix: Penalty Function --------------------------------------------------------
\subsection{Penalty Function}\label{code:MatlabPenalty}
\begin{figure}
\centering
\setlength\fboxsep{0pt}
\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=0.5cm 2.5cm 2.25cm 2.0cm,clip=true,scale=0.6]{MLB_Code_Penalty}}
\caption{"Penalty Function"}
\end{figure}

The figure is displaced. I've not had this problem when I just added an appendix by simply creating a new section{}. Any Advice.

JTZ
  • 91

1 Answers1

2

Well, you can always use the listings package to avoid using a figure (take a look at this post: How to add line numbers to a program listing/code?)

Now, regarding your appendix... are you sure you don't prefer to use the \appendix environment?

Your document would be something like this (on the mail file):

\documentclass{report}

\usepackage{listings}

\begin{document}

\include{chapter} % Include all your chapters here

\appendix
\include{yourappendixfile}

\end{document}

where yourappendixfile would be something like:

\chapter{Appendix title}

\section{Penalty function}
%You can write here your code, or import it from a file, using:
\lstinputlisting[language=Matlab]{./Code/penaltfunc.m}


\section{Cost function}
Mario S. E.
  • 18,609