3

We are preparing an audiobook transcript for a complex book that has many tables and figures. We have created a macro called \print{} for text that only appears in the printed book and another one \audio{} that only appears in the audiobook. That all works.

We have done a lot of \renewcommand things to turn off lots of special formatting.

I am looking for a solution that will allow us to specify alternative text for figures and tables and have them suppressed and have the alternative text appear. It is okay if the alternative text appears in the precise point where we defined the float, but it would be better if it defined a new command that we could then put where we wished.

Any thoughts on how to do this? I tried \renewenvironment but couldn't figure out how to turn off printing within the environment. Turning it into a comment environment didn't work.

EDIT

For example, here is a simple document:

\documentclass{article}
\newcommand{\audio}[1]{}

%% INSERT SOMETHING HERE TO MAKE THE {figure} disappear.

\begin{document}

The first paragraph.

\audio{This is the alternative text for the figure below.}

\begin{figure} This is a figure. \caption{This is the caption.} \end{figure}

The second paragraph.

\end{document}

What can I insert at the comment to make the {figure} not print?

vy32
  • 4,780
  • Please elaborate on "Turning it into a comment environment didn't work." What exactly did you try, and which error and/or warning messages (if any) did you get? – Mico Mar 19 '22 at 11:15
  • You can have a look at how the package endfloat works - it puts all the floats at the end with a [figure 8 about here] at the definition point. Maybe a good starting point... – Rmano Mar 19 '22 at 12:52
  • For clarification: does your example code in this question contain the alternative text that you want to show? If no, how do you want to define the alternative text? If yes, is it the caption? Do you want to output any indication that there used to be a figure, or you just want to remove the complete figure from the output? What about figure references in the text, should they remain as-is? – Marijn Mar 20 '22 at 15:43
  • It doesn't include the alternative text. I would be happy to do that with a command before the figure, or with my \audio{} macro. I can add it. – vy32 Mar 21 '22 at 14:59

1 Answers1

3

You can use

\usepackage{environ}
\RenewEnviron{figure}{}

The environ package captures the body of the envieonment in the macro \BODY. Thus, if you don't use that, the enviuronment content is suppressed.

enter image description here

Code:

\documentclass{article}
\newcommand{\audio}[1]{}

%% INSERT SOMETHING HERE TO MAKE THE {figure} disappear. \usepackage{environ} \RenewEnviron{figure}{}

\begin{document}

The first paragraph.

\audio{This is the alternative text for the figure below.}

\begin{figure} This is a figure. \caption{This is the caption.} \end{figure}

The second paragraph.

\end{document}

Peter Grill
  • 223,288