TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

Fullwidth of a float
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

Google c.t.t.

Google d.c.t.t.

 


 


To get a float with a total width of text- and marginparwidth and the caption only in the margin write in preamble (example for figure-float)
\usepackage{graphicx} 
\newlength\fullwidth
\setlength{\fullwidth}{\textwidth}
\addtolength{\fullwidth}{\marginparwidth}
\addtolength{\fullwidth}{\marginparsep}
\makeatletter
\newcommand\fwfig[3]{% label tag, graphics spec, caption
  \begin{figure}
    \edef\fwf@side{\if@twoside \ifodd 0\fwf@pageref{#1}l\else r\fi \else l \fi}%
    \makebox[\textwidth][\fwf@side]{%
      \vbox to\topskip{}%
      \parbox[t]{\fullwidth}{%
    	\centering \includegraphics[width=\fullwidth, height={!}]{#2}\par
    	\if\fwf@side l\raggedleft\else\raggedright\fi
    	\parbox[t][\z@][t]{\marginparwidth}{%
          \caption{#3}\label{#1}}\par
    }}%
  \end{figure}%
}
\def\fwf@pageref#1{%
  \expandafter\expandafter\expandafter
  \fwf@secondofmany\csname r@#1\endcsname\@empty\@nil
}
\def\fwf@secondofmany#1#2#3\@nil{#2}%

\makeatother
Then you can write in the text in TeX (red) something like
some text ...
\fwfig{fig:foo}{foo.eps}{Some long caption to see what it happens...}
some more text
and a ref to \ref{fig:foo}
This code works only for the book-documentclasses, otherwise you have to modify the code.

It's also possible to overwrite the existing figure/table float-environment if you like this for all floats.

To get the capter also over the fullwidth you can modify the above code. For a oneside article document you can simplify it to:

\newcommand\fwfigleft[4]{% label tag, graphics spec, caption
 \begin{figure}[!htb]
  \makebox[\textwidth][r]{%
    \vbox to\topskip{}%
    \parbox[t]{\fullwidth}{%
 	\centering \includegraphics[#4]{#2}\par
    	\raggedright
	\parbox[\z@]{\fullwidth}{%
     	  \caption{#3}\label{#1}%
       	}%
	\par
    }}%
 \end{figure}%
}
There is now a forth parameter for the width. The code for the following was:
\fwfigleft{logo}{cats.eps}{Some long caption to see what it happens...%
Some long caption to see what it happens...%
Some long caption to see what it happens...%
Some long caption to see what it happens...}{width=\fullwidth, height={!}}

local time: Thu Nov 14 18:13:50 CET 2019 ; file is: 141.093888888889 days old
contact webmaster _at_ TeXnik.de