Skip to content
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

Add a lof and lot options to docx output #8245

Closed
nicola-lunghi opened this issue Aug 24, 2022 · 2 comments
Closed

Add a lof and lot options to docx output #8245

nicola-lunghi opened this issue Aug 24, 2022 · 2 comments

Comments

@nicola-lunghi
Copy link

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?

@bandel65
Copy link

+1 for this; when documentation for LOF and LOT are updated in conjunction with this enhancement, not need to use native_numbering extension for it to work correctly.

@acxz
Copy link
Contributor

acxz commented Jul 23, 2024

Related issue: #8160

For additional information regarding this: quarto-dev/quarto-cli#2464 (reply in thread)

@nicola-lunghi "Image Caption" and "Table Caption" should be used instead of "Figure" and "Table".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants