0

My float border, regardless of the image size, is always wider than the textwidth. Reducing the textwidth percentage simply makes the vertical size small (as it keeps aspect ratio) but does not make the float border any smaller See image, note the border extends beyond the textwidth:

reducing the textwidth percentage simply makes the vertical size

%DOCUMENT PREPPING%
%Defines Document Class
\documentclass[]{article}
%Load requried packages
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage{hyperref}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{placeins}
\usepackage{float}
%defines foats (i.e. figures/pictures) as having a border
\floatstyle{boxed} 
\restylefloat{figure}
%Assigns image directory
\graphicspath{ {images/}}
%declares language mapping
\DeclareLanguageMapping{british}{british-apa}
%defines bib files
\addbibresource{C:/Users/20511181/Google Drive/Learning/Reviews/library.bib}
%Defines command to hide @ for email spam
\newcommand{\at}{\makeatletter @\makeatother}
%
%Figure Information. Note, DOCUMENT INFO OMITTED%
\begin{figure}[!ht]
    \includegraphics[trim=0cm 0cm 10cm 0cm, width=0.6\textwidth]{workloadcurve.png}
    \caption{Hypothesised workload curve from \parencite{Hart1988}.}
\end{figure}
\FloatBarrier

Example document:

%DOCUMENT PREPPING%
%Defines Document Class
\documentclass[]{article}
%Load requried packages
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{float}
%defines foats (i.e. figures/pictures) as having a border
\floatstyle{boxed} 
\restylefloat{figure}
%DOCUMENT INFORMATION%
%Title Information
\title{Image Test}
\author{Test}
\date{Last Updated: November, 2015}
%Begin document
\begin{document}
\maketitle
%start first section
\section{Introduction}
\clearpage

\begin{figure}[!htb]
    \includegraphics[width=0.8\textwidth]{example-image.jpg}
    \caption{The paper and pencil version of the NASA-TLX.}
\end{figure}

\end{document}
  • Welcome to the site! It would help if you made your example a document that people could test (removing presumably irelevant packages such as lipsum, csquotes etec, and using ``example-image` as the image name (which is a sample image that most people have already in their tex distribution) – David Carlisle Nov 19 '15 at 9:02
  • 1
    unrelated but \newcommand{\at}{\makeatletter @\makeatother} is equivalent to \newcommand{\at}{@} – David Carlisle Nov 19 '15 at 9:03
  • Is there a suggested protocol for uploading an example document? – Michael Anderson Nov 19 '15 at 9:12
  • Weirdly in the example image, the border is going wider than the textwidth. This perplexes me. – Michael Anderson Nov 19 '15 at 9:21
  • In the complete document as posted in the edited question the border is textwidth exactly. – David Carlisle Nov 19 '15 at 9:28
0

The float boxed style is always slightly wider than \textwidth. If you don't want the box around the caption, just put an \fbox{..} around the image.

\documentclass{article}
\usepackage{showframe}
\usepackage{mwe}

\begin{document}

\begin{figure}
\fboxsep=1em
\fboxrule=1pt
\fbox{\begin{minipage}{\dimexpr \textwidth -2\fboxsep-2\fboxrule}
\centering\includegraphics[width=0.8\textwidth]{example-image}%
\caption\blindtext
\end{minipage}}
\end{figure}

\end{document}

full page with frame


Here I implemented everything as an environment.

\documentclass{article}
\usepackage{environ}
\usepackage{showframe}
\usepackage{mwe}

\NewEnviron{boxedfigure}[1][]%
{\begin{figure}[#1]%
 \fboxsep=1em
 \fboxrule=1pt
 \fbox{\begin{minipage}{\dimexpr \textwidth-2\fboxsep-2\fboxrule}
 \BODY
 \end{minipage}}%
\end{figure}}

\begin{document}

\begin{boxedfigure}
\centering\includegraphics[width=0.8\textwidth]{example-image}%
\caption\blindtext
\end{boxedfigure}

\end{document}

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.