Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In addition to the very useful discussion Figures on left pages, text on right ones with class book, numbering only on right pages, I would like to handle 2 other features:

  • the suppression of blank pages automatically inserted by book,
  • the possibility to switch between figure and table captions.

Regarding the first, 3 blank pages are added before a new chapter (probably also before a new part) where only 1 should be. I managed to remove one redefining \chapter as follows (removing the first line involving \clearpage) but not the other.

\renewcommand\chapter{
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}

For the second, I defined a new command \switchcaption as follows which I call before and after a table respectively with "table" and "figure" as argument.

\newcommand\switchcaption[1]{\def\@captype{#1}}

By the way, I would be very interested in better understanding

  • when it is useful to use directly \def instead of \(re)newcommand (\newcommand\@captype{figure} seems to work just as well as \def\@captype{figure}),
  • when it is needed to work within \makeatletter \makeatother (apparently \newcommand works differently in both cases: it "reads" the new command name with subsequent braces outside \makeatletter \makeatother and without braces otherwise),
  • why \addfig definition needs two statements (one for \@addfig and another apparently for its argument).

Thank you very much in advance for your help!

share|improve this question
1  
I'm afraid you're asking two completely different questions here, and that they should be asked separately. Anyway, as far as I know for question (2a): don't use \def, and for (2b): it's needed when you tamper with TeX internal macros which have @ in their names. –  Axioplase Oct 27 '11 at 0:48
    
For your first two btw's see tex.stackexchange.com/questions/655/… and tex.stackexchange.com/questions/8351/…. –  Caramdir Oct 27 '11 at 0:50
    
Thank you for your fast follow-up! By the way I finally worked out more elegant (and suitable) solutions to the above-mentionned issues. The blank pages were actually linked to the page break inserted by \include (I am writing a thesis...). Using \input instead solves the problem (without redefining \chapter). In addition, I managed to avoid blank pages at the end of the document redefining \blankpage to stop recursion (\renewcommand{\blankpage}{}). To define table captions, I realised that I could use the command \captionof provided by the caption package I am using anyway. –  Benoît Bidaine Oct 27 '11 at 0:51
    
Regarding your choice of \include or \input, also see: tex.stackexchange.com/questions/246/… –  Werner Oct 27 '11 at 1:45
add comment

1 Answer 1

After viewing the comments, it seems like the only thing left (even though it is actually not in question form), is to efficiently switch between table and caption. You mention that you currently do this manually:

\switchcaption{table}% Switch to table caption
\begin{table}[..]
   ...
\end{table}
\switchcaption{figure}% Switch to figure caption

This manual interaction could be avoided by adding some code to the beginning and ending of the table environment. Such "patching" is possible using the etoolbox package. It provides \AtBeginEnvironment{<env>}{<code>} and \AtEndEnvironment{<env>}{<code>} (also \BeforeBeginEnvironment{<env>}{<code>} and \AfterEndEnvironment{<env>}{<code>}) to insert <code> at the beginning/end of environment <env>. A little bit more efficient would be to just add:

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\AtBeginEnvironment{table}{\def\@captype{table}}% Switch to table captions at beginning of table environment
\AtBeginEnvironment{figure}{\def\@captype{figure}}% Switch to figure captions at beginning of figure environment
\makeatother

to your document preamble that should switch as needed depending on the environment used.


Edit: The above "solution" may be moot if you are using the figure environment for all your figures and tables. If that is the case, the your \switchcaption combination will still be necessary.

To that end, note that you can still use the table environment within the command \addfig, which necessarily modifies the caption to read Table x: .... This is a common misinterpretation of the table and figure environments, stemming from their respective names. They are merely wrappers for any content, allowing you to place \includegraphics commands inside table and a tabular (say) inside figure.

share|improve this answer
    
When the caption package is used please don't use \def\@captype{table} but \captionsetup{type=table} instead. This latter one will not only define \@captype but also apply table-local caption options, set an hyperref anchor (if hyperref is used), prepare the environment for sub-figures resp. sub-captions etc. –  Axel Sommerfeldt Oct 27 '11 at 6:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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