Skip to content

Add a lof and lot options to docx output #8245

Closed
@nicola-lunghi

Description

@nicola-lunghi

see also #458

Hi,
I was wondering if it would be complicated to add support for lot, lof in docx / odt
the toc works nice in the current version.

Something similar to this should work

makeLOF :: (PandocMonad m) => WriterOptions -> WS m [Element]
makeLOF opts = do
  let lofCmd = "TOC \\h \\z \\c \"Figure\""
  return
    [
      mknode "w:p" [] [
        mknode "w:pPr" [] [
          mknode "w:pStyle" [("w:val","TableofFigures")] (),
        ], -- w:pPr
        mknode "w:r" [] [
          mknode "w:fldChar" [("w:fldCharType","begin"),("w:dirty","true")] (),
          mknode "w:instrText" [("xml:space","preserve")] lofCmd,
          mknode "w:fldChar" [("w:fldCharType","separate")] (),
          mknode "w:fldChar" [("w:fldCharType","end")] ()
          ] -- w:r
      ] -- w:p
    ]

Now I need someone that knows haskell to verify it and add the missing bits :-) anyone?

I've takenthe xml from the examples here and adapted the TOC code

        public static void AddTof(WordprocessingDocument doc, XElement addBefore, string switches, int? rightTabPos)

            string xmlString =
@"<w:p xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'>
  <w:pPr>
    <w:pStyle w:val='TableofFigures'/>
    <w:tabs>
      <w:tab w:val='right' w:leader='dot' w:pos='{0}'/>
    </w:tabs>
    <w:rPr>
      <w:noProof/>
    </w:rPr>
  </w:pPr>
  <w:r>
    <w:fldChar w:fldCharType='begin' dirty='true'/>
    <w:instrText xml:space='preserve'> {1} </w:instrText>
    <w:fldChar w:fldCharType='separate'/>
    <w:fldChar w:fldCharType='end'/>
  </w:r>
</w:p>";

Note that to get a List of Tables word seems to do the same but with

  let lotCmd = "TOC \\h \\z \\c \"Table\""

instead of

  let lofCmd = "TOC \\h \\z \\c \"Figure\""

I think it simply replaces Figures and Table -> probably could be added as an input to the function

Anyone can help?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions