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

Abstract has no title when converting markdown to docx #8702

Closed
joezhouchenye opened this issue Mar 16, 2023 · 11 comments
Closed

Abstract has no title when converting markdown to docx #8702

joezhouchenye opened this issue Mar 16, 2023 · 11 comments

Comments

@joezhouchenye
Copy link

Describe your proposed improvement and the problem it solves.

Add a similarly option like reference-section-title to abstract section.

Here's the result that I would like to have.

image

@jgm
Copy link
Owner

jgm commented Mar 18, 2023

I made it use a localized term for "Abstract" (will depend on lang). We could add the ability to override this using abstract-title if necessary, but maybe the localized term is enough?

@joezhouchenye
Copy link
Author

What I mean is to add the "Abstract" title to the output .docx document.

Anyway, I use a VBA macro as a workaround:

Sub AbstractTitle()
    Dim i As Integer
    
    i = 0
    
    For Each para In ActiveDocument.Paragraphs
        i = i + 1
        If para.Style = "Abstract" Then
            ActiveDocument.Paragraphs.Add Range:=para.Range
            ActiveDocument.Paragraphs(i).Range.Text = "Abstract" & vbCr
            ActiveDocument.Paragraphs(i).Style = wdStyleHeading1
            Exit For
        End If
    Next
End Sub

From the Pandoc User's guide abstract-title is "title of abstract, currently used only in HTML and EPUB".

I have tried HTML output, but no abstract part is shown in the generated HTML file.

For latex, abstract-title doesn't work as well.

A workaround to use custom abstract title for latex is:

header-includes:
  \renewcommand{\abstractname}{My Very Own Summary}

So far, I couldn't say this is a completed feature.

@jgm
Copy link
Owner

jgm commented Mar 18, 2023

What I mean is to add the "Abstract" title to the output .docx document.

Yes, and that's exactly what it does now! (with this commit)

@jgm
Copy link
Owner

jgm commented Mar 18, 2023

abstract-title could be implemented for docx and latex, if there's a reason to. (That is, if people really need the title of the abstract to be something different from "Abstract" as localized to their language.) But this would be better made a separate issue.

@zero0n3
Copy link

zero0n3 commented Jun 7, 2023

Hello, could you add ad example in the documentation on how to use it? Because i'm trying but without success. Thanks

@joezhouchenye
Copy link
Author

joezhouchenye commented Jun 7, 2023

Have you updated pandoc to the latest version? It does add "Abstract" now, but the added "Abstract" has the same style as the abstract content which is not desired. I want the abstract title to be bolded and center-aligned, so a macro in Word is still needed. It would be better to make abstract title the style of heading 1, just the same as the reference title.

@zero0n3
Copy link

zero0n3 commented Jun 7, 2023

yes I did the update and in fact now it adds Abstract to me at the beginning.
I usually use md to docx conversion.
In the files, at the top, I have this header (later used with the yaml_metadata_block extension)

---
lang: it-IT
abstract: "blah blah blah"
---

Meanwhile, the title "Abstract" is not translated according to the language and furthermore, even adding there, the variable
abstract-title: 'some title'
that value is not read and I still have the title "Abstract"
So where am I doing wrong?

@joezhouchenye
Copy link
Author

abstract-title could be implemented for docx and latex, if there's a reason to. (That is, if people really need the title of the abstract to be something different from "Abstract" as localized to their language.) But this would be better made a separate issue.

As mentioned above, abstract-title will have no effect in docx and cannot be translated automatically.

@zero0n3
Copy link

zero0n3 commented Jun 7, 2023

abstract-title could be implemented for docx and latex, if there's a reason to. (That is, if people really need the title of the abstract to be something different from "Abstract" as localized to their language.) But this would be better made a separate issue.

As mentioned above, abstract-title will have no effect in docx and cannot be translated automatically.

OK understood. Sorry, I misunderstood then and I thought it worked, at least the version translated into the language of the document, even on docx files

@jgm
Copy link
Owner

jgm commented Jun 7, 2023

Localization of the term "Abstract" is supposed to occur. So if it is not, it may be a bug.

@jgm
Copy link
Owner

jgm commented Jun 7, 2023

I see the bug and I will fix it now.

jgm added a commit that referenced this issue Jun 7, 2023
See #8702, which was only partially implemented before.
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