[texhax] refart with package float a hack for caption over the float

Ron RJF Fehd ron.fehd.macro.maven at gmail.com
Fri Sep 13 18:36:28 CEST 2013

This was an interesting piece of detective work:
I had to open the \jobname.toc file and squint at it
and wonder what is that trailing argument?

\contentsline {section}{\numberline {1}One}{1}{section.1}

Oh, yeah: that last {section.1} is a hyperlink

The hyperref argument is not in the manual I have: LaTeX Companion, 2e, pg
section 2.3.1 Entering information into the contents files.

Since I could not get the caption on top of the program listing
by using the float package command \floatstyle{plaintop}
I decided to use

That did not work the way I wanted; I eventually got this working.

Ron Fehd  {SAS} macro maven

% command programCaption
% description: provides movable caption of float named program
% purpose    : package{float} floatstype{plaintop} does not work
% tricks     : 1 add hyperref.hypertarget
%            : 2 add hypertarget reference at end of contentsline
\hypertarget{program.\theprogram}{Program.\theprogram\ #1}%
{\protect\numberline{\theprogram}{\ignorespaces #1}}{\thepage}%
{program.\theprogram}}%this last argument is for hyperref
%\addcontentsline{lop}{section}{#1}%saved for comparison
}%end programCaption
\title{\jobname}\author{R.J. Fehd}\date{draft of \today}
\section*{Abstract}This document is a demonstration of the
\href{http://www.ctan.org/pkg/float}{Float package} within
\texttt{refart} class showing a hack, kludge or workaround
for a caption of a program that can be moved around.

\listof{program}{List of Programs}
\section{One}Some text here.
This sentence is about
\programCaption{Caption is where author puts it.}
/* name: program that does something */
\programCaption{Caption is wherever the author decides to put it},
followed by more text.

I got this working by comparing the listings of \jobname.toc and

This is the text of the file \jobname.lop.

\contentsline {program}{\numberline {1}{\ignorespaces Caption is
\contentsline {program}{\numberline {2}{\ignorespaces Caption ... author
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20130913/cd4135d4/attachment.html>

More information about the texhax mailing list