-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support short + long headers in sections and chapters (such as \chapter[short]{long long long} in LaTeX) #3682
Comments
I would guess that this is out of scope for the pandoc AST. However, you can enter the long title as an attribute:
then write a pandoc filter to convert this to the rawTeX you mentioned... |
See #2447 and the discussion there. I can see adding special support in the LaTeX and Markdown readers and writers for a |
I would love to see this feature implemented. In the meantime, for future googlers, here is my filter that does the job : #!/usr/bin/env python
from pandocfilters import toJSONFilter, RawBlock, get_value, stringify
SHORT_ATTRIBUTE_ID = 'short'
def f(key, value, format, meta):
if not (format == 'latex' and key == 'Header'):
return
level, data, _ = value # level, data, internal_pandoc
_, classes, keyvals = data # ident, classes, keyvals
short, _ = get_value(keyvals, SHORT_ATTRIBUTE_ID) # short, res
if not short:
return
if classes:
raise Exception(
'short-title-for-toc.py: If class "%s" is used, I cant handle another one (Header="%s")'
% (SHORT_ATTRIBUTE_ID, stringify(value))
)
try:
tag = {
-1: 'part',
0: 'chapter',
1: 'section',
2: 'subsection',
3: 'subsubsection',
}[level]
except:
raise Exception('short-title-for-toc.py: level %d not handled' % level)
return RawBlock('latex', '\\%s[%s]{%s}' % (tag, short, stringify(value)))
if __name__ == '__main__':
toJSONFilter(f) Disclaimer: hacked in a few minutes, probably far from perfect |
short-captions.lua is a filter that adds support for short captions on tables and figures. See #2447 @gtuckerkellogg Does it also work with chapter titles? |
@Nodraak I love your filter. It works for me if there is only |
Note: Updated filter with handling of |
While filters such as those suggested in #2447 and here will work for standard LaTeX output, it seems hopeless for Beamer. It does not seem possible to push any data between \begin{frame} ... \end{frame} and a \section[...]{...} is not seen to be treated specially for this, so it looks to be up to some internal sauce to get this right. |
I have run into some downstream (
bookdown
) uses ofpandoc
, where it'd be really nice if pandoc supported short and long headers in sections and chapters (here and here).If the origin and target formats support it, it would be nice to be able to pass on both the short and long version of headers, so that they can be layouted accordingly.
(This is often an issue in navbars, page headers and tables of content, where you'd usually only want quite short headers, but at the actual start of the chapter, you might want something longer).
LaTeX supports this as:
I understand if this is considered out of scope, we mainly just want to know whether this might at some point be a feature or whether we have to hack around it.
(also paging @VerenaKasztantowicz).
The text was updated successfully, but these errors were encountered: