oduwsdl / wsdlthesis

ODU WS-DL Thesis/Dissertation LaTeX Template
MIT License
3 stars 11 forks source link

List of Figures should only have first line of caption #36

Open machawk1 opened 5 years ago

machawk1 commented 5 years ago

Per page 49 of the Dissertation Guideline. Currently, the full caption is shown.

While this could be remedied with duplicating the text, \caption[lorem ipsum]{lorem ipsum}, the text must exactly match and only be one sentence, which seems like it is self-conflicting but this what the guide states.

I have figured out a way (src) to fix this but it would be far more elegant if it overrode the original caption command.

Add this to custommacros.sty:

\newcommand\slcaption[1]{\caption[\getfirst#1\relax.]{#1}}
\def\getfirst#1.#2\relax{#1}

then replace instances of \caption{} with \slcaption.

machawk1 commented 5 years ago

This assumes that you captions have a ".", I think. Most of mine do, because they're multi-sentence ;)

Also, watch out for subcaptions, subrefs within captions, and various \protect commands, which might trip it up.

ibnesayeed commented 5 years ago

I don't think it is a bug. The class file is not supposed to (and cannot) automagically fix everything. There will be things that can be documented so that people can manually take care of necessary steps. It is a well-known standard LaTeX behavior of many commands (such as \caption, \chapter, and \section etc.) that also introduce an entry in the index/ToC to have an optional parameter to customize what goes in the index if it is different from what is shown in the document body.

However, being able to automate it to comply with the style guide in a more effortless manner would be great. I can think of two potential means of accomplishing it. First approach would be to define a helper macro, say, \oducaption in the custommacros.sty file. This would require some documentation and the users need to know that they should use that macro instead. A more seamless approach would be to redefine existing \caption command. This might cause surprises for users who are unaware of the fact that the class overrides such a fundamental command. In both of these approaches, it is worth noting that identifying the "first full sentence" may be trickier than one thinks. The caption might have decimal numbers or domain names with dots in them or some captions might not even have a dot (say, the sentence ends on a question or exclamation mark, or the user likes to write small captions without placing a a dot at the end).

machawk1 commented 5 years ago

If the CLS file generates a PDF by default (without the user's customizations) that does not comply with the dissertation style guide, it is a bug.

I like the idea of specifying an attribute for the document to get caption to behave differently with graceful degradation to the default behavior if not specified.

As above, there is likely a more sophisticated macros that can account for "." literals in the caption that do not indicate the end of a sentence. Requiring the user to modify their caption to manually indicate this (e.g., \shortCaptionEndsHere in \caption{}) seems like the wrong way to go.

The solution I proposed above is generally working for me. I am hoping we can come up with something more elegant for those that have to deal with this in the future (e.g., you, @ibnesayeed ;) ).