@@ -743,14 +743,16 @@ sectionHeader :: Bool -- True for unnumbered
743743sectionHeader unnumbered ident level lst = do
744744 txt <- inlineListToLaTeX lst
745745 plain <- stringToLaTeX TextString $ concatMap stringify lst
746− let noNote (Note _) = Str ""
747− noNote x = x
748− let lstNoNotes = walk noNote lst
746+ let removeInvalidInline (Note _) = []
747+ removeInvalidInline (Span (id', _, _) _) | not (null id') = []
748+ removeInvalidInline (Image _ _ _) = []
749+ removeInvalidInline x = [x]
750+ let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
749751 txtNoNotes <- inlineListToLaTeX lstNoNotes
750752 -- footnotes in sections don't work (except for starred variants)
751753 -- unless you specify an optional argument:
752754 -- \section[mysec]{mysec\footnote{blah}}
753− optional <- if unnumbered || lstNoNotes == lst
755+ optional <- if unnumbered || lstNoNotes == lst || lstNoNotes == []
754756 then return empty
755757 else do
756758 return $ brackets txtNoNotes