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


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}
\fbox{\includegraphics[trim=0.5cm 2.5cm 2.25cm 2.0cm,clip=true,scale=0.6]{MLB_Code_Penalty}}
\caption{"Penalty Function"}

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


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):




\include{chapter} % Include all your chapters here



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:

\section{Cost function}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.