jbezos / soulpos

MIT License
0 stars 1 forks source link

Underlining doesn't work in figure captions #1

Open mpetroff opened 4 years ago

mpetroff commented 4 years ago

Thanks for writing this package; I had a need for a dashed underline, and this package produced much more pleasing results than the ulem package or the various snippets I could find on Stack Exchange.

However, it doesn't work in figure captions (the issue appears to apply to all floats). For underlines in captions, the intermediate output is written to the log / console instead of writing to the *.upa file. Here's a minimum example:

\documentclass{article}

\usepackage{soulpos}
\ulposdef{\uldash}{\makebox[\ulwidth]{\xleaders\hbox to.3em{\hss\rule[-.6ex]{.25em}{0.4ex}\hss}\hfill}}

\begin{document}

\uldash{Short underline}

\begin{figure}
\uldash{Medium underline}
\caption{\uldash{Loooooooooooooooooong underline}}
\end{figure}

\end{document}

that produces: error-before-change

I'm able to fix the part about not writing to the *.upa file by adding \immediate to the start of line 24 of soulpos.sty, changing it from \openout\ulp@out=\jobname.upa\relax to \immediate\openout\ulp@out=\jobname.upa\relax. After the change, the intermediate output is now written to file, but the underlines are drawn in the incorrect order: error-after-change

It seems that when writing the *.upa file, the underlines from the float are written first, but when drawing the underlines, the underline from outside the float is drawn first.

There's another issue where underlines are not drawn in captions if the caption spans more than one line.