# Images are not included. "Float too large for page ..."

I finally decided to follow up on this question, and try to fix some of the problems in the document from Project Gutenberg.

Given this TEX file of a book with typos, how might I produce a corrected version. What tools and supporting packages are necessary or useful?

https://www.gutenberg.org/ebooks/43006

This is a read-only link to my copy of the project. It works for me without authentication.

I have discovered that the graphics are not being added to the PDF when compiled. These are the commands which seem to deal with including images.


%% Diagrams %%
\newcommand{\Graphic}[2][]{%
\Pagelabel[fig]{#2}%
\ifthenelse{\equal{#1}{}}{%
\includegraphics{./images/fig#2.pdf}%
}{%
\includegraphics[width=#1]{./images/fig#2.pdf}%
}%
}
% \Figure{figure number}
\newcommand{\Figure}[2][]{%
\begin{figure}[hbt!]
\centering
\Graphic[#1]{#2}
\end{figure}\ignorespaces%
}


This is an example log warning message:

<./images/fig1.pdf, id=481, 614.295pt x 794.97pt>
File: ./images/fig1.pdf Graphic file (type pdf)
<use ./images/fig1.pdf>
Package pdftex.def Info: ./images/fig1.pdf  used on input line 1727.
(pdftex.def)             Requested size: 614.29349pt x 794.96806pt.

Overfull \hbox (280.04474pt too wide) in paragraph at lines 1727--1727
[][]
[]

LaTeX Warning: Float too large for page by 357.73434pt on input line 1727.



How can I fix this?

• The link have restricted access, so just guessing...Making the width (#1) smaller?
– Fran
Dec 21, 2021 at 19:50
• I changed the link to point to the original project. I don't see anywhere that a width parameter is set for images. But I know very little about how LaTeX works. Dec 22, 2021 at 15:36
• In the macro definition that you showed there are a width=#1 where #1 mean the first argument of the macro. So the width of the image could be what you type after \Graphic between braces (it could be some like 15cm, 125pt, 14em or 0.5\linewidth).
– Fran
Dec 22, 2021 at 18:03
• The new link do not work. Please do not use external links that even working today, could will be broken tomorrow, of no use for new readers. Post in the question a minimal working example (MWE), i.e., the complete compilable (working) document, showing this problem (example) but removing all the irrelevant text and code (minimal) and without generating another type of errors by careless deletions (remove a \end{...} without remove \begin{...}, remove a packages that still is used in the not removed part, etc.).
– Fran
Dec 22, 2021 at 18:20
• sorry about the access. I didn't do anything special to access the original project. Apparently the other person correctly predicted my credentials when creating it. Nonetheless, the source is also available at gutenberg.org/ebooks/43006 But I have no tool other than overleaf with which to compile it. I do not have the skills required to produce a MWE. I jumped into working with a complete book. I'm trying to fix typos, and learn physics, not LaTeX. No offense intended. Dec 22, 2021 at 21:45

Command in text \Figure{1} include a float with the fig1.pdf using the original width of the image and so on in the remaining figures, but the macro is defined to allow also an optional argument, by default empty (that mean the [2][]...). If you use the optional argument, it will be used in place of #1 in the macro definition to make the image smaller or bigger when passed to \Graphic macro (also as an optional argument). Here you can see that the optional argument must be typed first and it must be delimited by square brackets instead of the curly brackets for mandatory arguments.

Therefore, the solution is type as optional argument a relative length (e.g. \Figure[.8\linewidth]{1} if you want the figure 1 with a width equal to the 80% of the width of the text), or an absolute width (e.g.\Figure[6cm]{1} if you want fixed width of 6 cm, irrespectively of the width of the lines of text).

Note also that because captions (e.g. "Fig. 1.") are part of the image, resize each image differently will produce ugly font size inconsistencies. Consider crop the images to remove these captions and include \par Fig. #2. just before \end{figure} in the definition of \Figure.

A MWE using the fig1.pdf in the same working directory (the \Graphic macro is changed to avoid the subdirectory for the images):

\documentclass[a4paper,twocolumn]{article}
% packages just for tuning the example:
\usepackage{lipsum} % dummy text
\usepackage[margin=4cm]{geometry} % custom margins
% packages used in macro definitions (not optional)
\usepackage{ifthen}
\usepackage{graphicx}
\usepackage{hyperref}

% Custom macros
\newcommand{\Pagelabel}[2][page]{\phantomsection\label{#1:#2}}

%% Diagrams %%
\newcommand{\Graphic}[2][]{%
\Pagelabel[fig]{#2}%
\ifthenelse{\equal{#1}{}}{%
\includegraphics{fig#2}%
}{%
\includegraphics[width=#1]{fig#2}%
}%
}
% \Figure{figure number}
\newcommand{\Figure}[2][]{%
\begin{figure}[hbt!]
\centering
\Graphic[#1]{#2}
\end{figure}\ignorespaces%
}

\begin{document}
\lipsum[1][1-3]
\Figure{1} % too big for this text (or too small for one column)
\lipsum[2][1-3]
\Figure[.8\linewidth]{1} % always fitting the margin
\lipsum[3][1]
\end{document}


BTW, learn to make a MWE is not learn LaTeX, is learn to isolate and expose correctly the problem, making all the tedious work except find the solution in order to maximize the probability of obtain help, while link to a large project is just the opposite.

I tried to open the image files from the project, and they didn't appear to be properly rendered. I looked on https://www.gutenberg.org/files/43006/43006-t/images/ and saw the dates on the image files are newer than the project I copied. I copied those files to my project, and all is now well with the images.