2

I am trying to remove all figures and tables in my document, but keep references inside the text still correct (i.e. figure 8/9/x).

I have found the following answer here which allows for all floats/tables to not be processed (and is good since I am already using this package).

However, I would like to still retain the figure counts/etc so there references to figures still work in the text. Furthermore, if I am using the subfloat package, it will also have to remove the sublabels (i.e. a) and b)).

MWE:

\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\usepackage{subfig}

%%% Remove the next two lines if you want the figures at their place    
\usepackage[nolists,nomarkers]{endfloat}
\renewcommand{\processdelayedfloats}{}

\usepackage{lipsum}% mock text

\begin{document}

\lipsum[1]

\begin{figure}
\includegraphics[width=.3\textwidth]{example-image-a}
\caption{Whatever}
\label{fig:A}
\end{figure}

\lipsum[2]

\begin{figure}
\includegraphics[width=.3\textwidth]{example-image-a}
\caption{Whatever}
\label{fig:B}
\end{figure}

\lipsum[3]

\begin{table}[htp]
A table
\caption{Something}
\label{tab:A}
\end{table}

\lipsum[4]

\begin{figure}[H]
\centering
\subfloat[]{\includegraphics[width=0.50\textwidth]{images/s.pdf}\label{sv}}
\hfil
\subfloat[]{\includegraphics[width=0.50\textwidth]{images/p.pdf}\label{pv}}
\caption{(a) shows the orthogonal plots of variables and their contribution on PC1 and PC2 while (b) highlights the individual contribution of each site. Ellipses for north and south in (b) are for 1 $\sigma$.}
\label{svp}
\end{figure} 

\end{document}
Neviem
  • 53
  • Why exactly do you want to remove the figures but keep the references? For somebody reading your document that must be confusing. If you think that loading the images takes too much time then you could also try if the demo package option for graphicx (i.e.,\usepackage[demo]{graphics}) does what you need (it does not load the image files but displays a placeholder instead, and all references and labels remain the same). – Marijn Jan 06 '20 at 17:32
  • 1
    This is due to the submission requirements of the journal. The tables/figures have to be provided as separate files to the manuscript (which I'ves plit by using endfloat and cutting the pdf). However, I want to also provide the source Latex code which exactly produces the manuscript (i.e. no figures or tables but with references). – Neviem Jan 06 '20 at 17:33
  • I see- however in that case the journal usually takes care of the image placement and the references in the text, they probably don't use LaTeX at all (especially if they also create a html version of your paper for online viewing). They will send you a draft version of the paper before publication, where you can check if all the references are ok. – Marijn Jan 06 '20 at 17:37
  • In this instance I believe they will purely use Latex (as that is one of their accepted formats and the one I am providing). I do agree the Latex source most likely could just ignore the references, but considering it is doable (I believe it will be with \renewcommand and some editing) I would rather do that. – Neviem Jan 06 '20 at 17:42
  • Another thought - the fact that figures and tables must be provided as separate files does not necessarily mean that they are not also allowed in the document, especially in the LaTeX source, right? Maybe the publisher just wants the files separately to enable them to compile your file, if they are indeed using LaTeX. Or to check requirements on file type, resolution, color, transparency, etc. Or to provide them separately for a html version, as mentioned before. None of those reasons implies that you should remove the images from your document. – Marijn Jan 06 '20 at 21:17
  • A manual way would be to add \usepackage[-20]{pagesel}, once you know that your document ends at page 20 and figures are from page 21 on. – egreg Jan 06 '20 at 21:32
  • @Marijn in my field it is not uncommon that journals require figures and tables to be uploaded separately and that they do not want either in the text as this makes it easier for the majority of users that want to upload Word files. There are not enough LaTeX users to really support that pathway despite them offering to compile the document on an ancient TeX system. – StrongBad Jan 06 '20 at 22:15

1 Answers1

2

Based on your MWE, I am not really sure what you want the output to be regarding the lists of tables and figures and if the tables should be in the text. Given the options to the endfloat package, I am assuming you really do not want lists of tables and figures and you want the tables in the text. I have never seen a journal with this particular set of requirements, but there are a lot of journals.

A robust solution that deals with arbitrary floating content and their locations, the use of long and short captions in the figures and lists, markers in the text, and cross referencing is a pain. For you particular MWE with the figure environments only including \includegraphics, a caption, a subfloat, and a label, the following should work.

  1. Add in the float and subfig packages so the MWE compiles
  2. Add a \label to each figure and table so cross referencing works
  3. Drop a lot of the functionality of the endfloat package
  4. Overload the \@makecaption, \includegraphics, and \subfloat macros so they do not do anything other than gobble their arguments

Note that if you use hyperref package patching \@makecaption might be more involved depending on how you want back references to behave.

The reason things are hard is that you need to output some of the contents of the float environment, in particular the label in order to get cross referencing to work, but you do not want the rest of the environment. There is probably some cool hack where you can redefine \label to gobble everything before and after it, but that is a lot of work.

\documentclass{article}
\usepackage{graphicx}

\usepackage{float}
\usepackage{subfig}

%%% Remove the next two lines if you want the figures at their place    

\makeatletter

\let\OldAtEndDocument\@enddocumenthook
\usepackage[figuresonly,nolists,nomarkers]{endfloat}
\let\@enddocumenthook\OldAtEndDocument
\efloat@AtEndDocument{\processdelayedfloats}
\renewcommand\efloatseparator{}
\renewcommand\efloatbegin{}
\renewcommand\efloatendlist{}

\renewcommand{\@makecaption}[2]{}
\renewcommand{\includegraphics}[2][]{}
\long\def\sf@@@subfloat#1[#2][#3]#4{#4\endgroup\ignorespaces}
\makeatother

\usepackage{lipsum}% mock text

\begin{document}
Figure \ref{fig:A} and \ref{fig:B} Table \ref{tab:A} and subfloat \ref{svp}, \ref{sv}, and \ref{pv}

\lipsum[1]

\begin{figure}
\includegraphics[width=.3\textwidth]{example-image-a}
\caption{Whatever}
\label{fig:A}
\end{figure}

\lipsum[2]

\begin{figure}
\includegraphics[width=.3\textwidth]{example-image-a}
\caption{Whatever}
\label{fig:B}
\end{figure}

\lipsum[3]

\begin{table}[htp]
A table
\caption{Something}
\label{tab:A}
\end{table}

\lipsum[4]

\begin{figure}[H]
\centering
\subfloat[]{\includegraphics[width=0.50\textwidth]{images/s.pdf}\label{sv}}
\hfil
\subfloat[]{\includegraphics[width=0.50\textwidth]{images/p.pdf}\label{pv}}
\caption{(a) shows the orthogonal plots of variables and their contribution on PC1 and PC2 while (b) highlights the individual contribution of each site. Ellipses for north and south in (b) are for 1 $\sigma$.}
\label{svp}
\end{figure}

\lipsum[5]


\end{document}
StrongBad
  • 20,495
  • Thank you - this seems to be more in the right direction. However, if I am using the 'subfloat' package - how could I find the command responsible for creating the sub labels (i.e. a) and b)) since these remain in the text? – Neviem Jan 06 '20 at 22:31
  • Have managed to do this using \captionsetup[subfigure]{labelformat=empty}, which still leaves ugly blank spaces. – Neviem Jan 06 '20 at 22:39
  • @Neviem that looks like you are using subfig and not subfloat. You should extend the MWE to include everything you need it to do. – StrongBad Jan 06 '20 at 22:44
  • have updated the MWE with an example where I use subfloat. – Neviem Jan 06 '20 at 22:52
  • @Neviem see edits – StrongBad Jan 06 '20 at 23:36
  • I am still seeing sublabels for figures, I have added the following 2 lines which provides almost the desired output: \captionsetup[subfigure]{labelformat=empty} \renewcommand{\efloatheading}[1]{\pagestyle{empty}}

    However (I edited the MWE before) if I would also like to remove tables, I am struggling to make the tabular environment eat up the arguments and nothing else.

    – Neviem Jan 06 '20 at 23:54
  • @Neviem you see sublabels with my MWE, because I don't? As for tables, as I said, things get harder if the floats can have arbitrary content. If you are using a tabular within the table float, you can use the environ package to gobble everything. – StrongBad Jan 06 '20 at 23:59
  • Not with the MWE now I have separated different files I've been testing. In my main file they were still visible due to some usage of sidesubfloat (and other caption work). I appreciate the above, thank you @StrongBad. Most likely will contact the editor because this seems to be obfuscating the latex code more than it will help standardize what they actually want... – Neviem Jan 07 '20 at 00:08
  • @Neviem just use endfloat and then cut the pages from the pdf. – StrongBad Jan 07 '20 at 00:11
  • that is what I did. I just don't want to use \usepackage[-20]{pagesel} inside the .tex file as I think it's just uncontrolled and more problematic. I have just put the figures and tables at the end with no page numbers/headings for the .tex submission and split the actual pdf into 3 for the manuscript upload. Either way, thank you for the help, will accept your answer as it's closest to desired behaviour. – Neviem Jan 07 '20 at 09:24