<div dir="ltr"><div><div><div><div>This was an interesting piece of detective work:<br></div>I had to open the \jobname.toc file and squint at it<br></div>and wonder what is that trailing argument?<br></div><br>\contentsline {section}{\numberline {1}One}{1}{section.1}<br>
<br>Oh, yeah: that last {section.1} is a hyperlink<br><br></div>The hyperref argument is not in the manual I have: LaTeX Companion, 2e, pg 46, <br>section 2.3.1 Entering information into the contents files.<br><div><br></div>
<div>Since I could not get the caption on top of the program listing<br></div><div>by using the float package command \floatstyle{plaintop}<br></div><div>I decided to use <br></div><div><div><div><div>\addcontentsline{lop}{section}{...}<br>
<br></div><div>That did not work the way I wanted; I eventually got this working.<br><br></div><div>Ron Fehd  {SAS} macro maven<br></div><div><br>\documentclass{refart}<br>\usepackage{float}\newfloat{program}{H}{lop}%[section]<br>
\floatstyle{plaintop}%<br>% command programCaption<br>% description: provides movable caption of float named program<br>% purpose    : package{float} floatstype{plaintop} does not work<br>% tricks     : 1 add hyperref.hypertarget<br>
%            : 2 add hypertarget reference at end of contentsline<br>\newcommand\programCaption[1]{%<br>\stepcounter{program}%<br>\hypertarget{program.\theprogram}{Program.\theprogram\ #1}%<br>\addtocontents{lop}{\protect\contentsline{program}%<br>
{\protect\numberline{\theprogram}{\ignorespaces #1}}{\thepage}%<br>{program.\theprogram}}%this last argument is for hyperref<br>%\addcontentsline{lop}{section}{#1}%saved for comparison<br>}%end programCaption<br>\title{\jobname}\author{R.J. Fehd}\date{draft of \today}<br>
\usepackage{fancyvrb,hyperref}<br>\begin{document}\maketitle<br>\section*{Abstract}This document is a demonstration of the<br>\href{<a href="http://www.ctan.org/pkg/float}{Float">http://www.ctan.org/pkg/float}{Float</a> package} within<br>
\texttt{refart} class showing a hack, kludge or workaround<br>for a caption of a program that can be moved around.<br><br>\tableofcontents<br>\listof{program}{List of Programs}<br>\section{One}Some text here.<br>This sentence is about<br>
\programCaption{Caption is where author puts it.}<br>\begin{program}<br>\begin{Verbatim}<br>/* name: program that does something */<br>\end{Verbatim}<br>\end{program}<br>\newpage<br>\section{Two}<br>\programCaption{Caption is wherever the author decides to put it},<br>
followed by more text.<br><br>I got this working by comparing the listings of \jobname.toc and \jobname.lop.<br><br>This is the text of the file \jobname.lop.<br><br>\begin{program}<br>\begin{maxipage}<br>\begin{Verbatim}[fontsize=\footnotesize]<br>
\contentsline {program}{\numberline {1}{\ignorespaces Caption is ...}}{1}{program.1}<br>\contentsline {program}{\numberline {2}{\ignorespaces Caption ... author decides}}{2}{program.2}<br>\end{Verbatim}<br>\end{maxipage}<br>
\end{program}<br>\end{document}<br><br></div></div></div></div></div>