rchaput / acronyms

Adds support for Acronyms, and List of Acronyms, to Quarto documents.
GNU General Public License v3.0
20 stars 2 forks source link

Formating the acronyms list #19

Closed PierreSolomon closed 3 months ago

PierreSolomon commented 4 months ago

Hello, Currently, the acronyms references are printed as:

ML
Machine Learning

Would it be possible to add an option so that it is printed as:

ML: Machine Learning

With the ML acronyms in bold? I think it would be useful for some documents.

rchaput commented 4 months ago

Hello,

It would be a nice feature indeed!

I am not sure yet how to provide this option, because people may want various ways to render the list (i.e., key in bold, description in italic, ...). The ideal would probable to have a "formatting" option that accepts Markdown templates, such as `"{{key}}: {{description}}"?

Also, I cannot work on acronyms for the time being, but I hope to resume progress soon.

A good solution, if you render to HTML, is to use CSS to style the acronyms list, which is actually a definition list.

This[https://www.the-art-of-web.com/css/format-dl/] [https://www.the-art-of-web.com/css/format-dl/]webpage[https://www.the-art-of-web.com/css/format-dl/] gives a few good examples on how to style a definition list, including some that look like what you want to do.

Otherwise, if you render to PDF, I am not sure how this works. Theoretically, the acronyms list is still rendered as a definition list, but I do not know how Pandoc translates this into LaTeX code. It may be possible to use a custom environment and to style it, but this is out of my knowledge.

Apr 23, 2024 13:57:52 PierreSolomon @.***>:

Hello, Currently, the acronyms references are printed as:

ML Machine Learning Would it be possible to add an option so that it is printed as:

ML: Machine Learning With the ML acronyms in bold? I think it would be useful for some documents.

— Reply to this email directly, view it on GitHub[https://github.com/rchaput/acronyms/issues/19], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AGZR5IKG5ZZMD3EYTYD3CD3Y6ZED7AVCNFSM6AAAAABGUXQJFKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2TQNRYHEYTINA]. You are receiving this because you are subscribed to this thread. [Tracking image][https://github.com/notifications/beacon/AGZR5IM6T2YBIR5RCNZTBXTY6ZED7A5CNFSM6AAAAABGUXQJFKWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHINIG4PA.gif]

PierreSolomon commented 4 months ago

Hello, Thank you for your answer. I'm rendering a docx document so the CSS solution won't work for me.

rchaput commented 4 months ago

Hello,

Sorry for the delay. I have implemented this feature in the latest version of acronyms. There is no release yet, so you must make sure you install it with quarto add rchaput/acronyms@master to get the latest.

Everything is described in the documentation; short version, you can add the following lines to your metadata:

---
acronyms:
  loa_format: '`**{shortname}**: {longname}`{=raw}'
---

It should output what you wanted (bold name, colon, description on same line). If you want it as a bullet list, you can add a hyphen at the beginning of the string:

---
acronyms:
  loa_format: '`- **{shortname}**: {longname}`{=raw}'
---

I hope it answers your issue, do not hesitate to leave a comment otherwise.

Pierre9344 commented 4 months ago

Hello,

I tried to use the options next to format the acronyms list but then, only the first acronyms is in the list of the rendered document. If I remove the options, all the acronyms are show. The second options to render as a bullet list work as it should.

---
acronyms:
  loa_title: ''
  insert_loa: false
  insert_unused: false
  insert_link: true
  loa_format: '`- **{shortname}**: {longname}`{=raw}'
  keys:
    - shortname: BM
      longname: Biomarqueur
    - shortname: ADN
      longname: "Acide Désoxyribonucléique"
    - shortname: ADNc
      longname: "ADN complémentaire"
    - shortname: ARN
      longname: "Acide Ribonucléique"
---
rchaput commented 4 months ago

Sorry for this, I think I know why it happens, I overlooked something when implementing the feature.

I will try to fix it in a way that works with most (all?) possible templates, and will get back to you when it's done.

rchaput commented 4 months ago

I think this should work now. Feel free to test again and tell me if something is still wrong.

PierreSolomon commented 4 months ago

Hello,

I just downloaded the latest version and now the acronyms list is printed correctly but my table of content disapear (this doesn't appen with the bullet point list). I'm rendering a docx document.

PierreSolomon commented 4 months ago

Just to be clear, the beginning of my document look like this:

---
title: "my title"
project:
  type: default

date: last-modified

format: 
  html:
    toc: true
    comments:
      hypothesis: true
    page-layout: full
    toc-depth: 4 
    theme: cosmo
    standalone: true
    embed-resources: true
    toc-title: "Table des matières"
    appendix-style: plain
  pdf:
    toc: true
    number-sections: true
    colorlinks: true
    cite-method: biblatex
    toc-depth: 4
    toc-title: "Table des matières"
    appendix-style: plain
    fontsize: "12"
    linestretch: "1.5"
  docx:
    toc: true
    number-sections: true
    toc-title: "Table des matières"
    highlight-style: github
    toc-depth: 4
    appendix-style: plain
    reference-doc: template.docx
editor: source

bibliography: ["BIBLIO.bib", "references.bib"]
link-citations: true
link-bibliography: true
csl: "nature.csl"

crossref: 
  labels: roman

filters:
  - acronyms
date: last-modified
editor: source
bibliography: ["BIBLIO.bib", "references.bib"]
acronyms:
  loa_title: ''
  insert_loa: false
  insert_unused: false
  insert_link: true
  loa_format: '`- **{shortname}**: {longname}`{=raw}'
  keys:
    - shortname: BM
      longname: Biomarqueur
    - shortname: ADN
      longname: "Acide Désoxyribonucléique"
    - shortname: ADNc
      longname: "ADN complémentaire"
    - shortname: ARN
      longname: "Acide Ribonucléique"
    - shortname: ARNt
      longname: ARN de transfert
    - shortname: miARN
      longname: micro-ARN
    - shortname: ARNm
      longname: ARN messager
    - shortname: ARNnc
      longname: ARN non-codants
    - shortname: ARNr
      longname: ARN ribosomique
    - shortname: SCZ
      longname: Schizophrénie
    - shortname: TSCZA
      longname: Troubles Schizo-Affectifs
    - shortname: TB
      longname: Troubles Bipolaire
    - shortname: DM
      longname: Dépression Majeure
    - shortname: ENCODE
      longname: Encyclopédie des éléments de l'ADN
 ---

\pagebreak

# Liste des abréviations {.unnumbered}

\printacronyms

\pagebreak

# Chapitre 1
rchaput commented 4 months ago

It's very weird. I do not see any reason for the table of contents to disappear with the code I've written.

On my machine, with the example you gave, I get the correct result, although the pagebreak between Table of Contents and List of Acronyms is not present in docx (but present in PDF).

Result with docx format (opened through Pages, hence the weird-looking table of contents):

image

Result with pdf format:

image

Result with html format (pagebreaks obviously are not present):

image

Maybe there is a problem with your template.docx file? Note that I slightly altered the metadata because of lacking files and repeated keys:

---
title: "my title"
project:
  type: default

date: last-modified

format:
  html:
    toc: true
    comments:
      hypothesis: true
    page-layout: full
    toc-depth: 4 
    theme: cosmo
    standalone: true
    embed-resources: true
    toc-title: "Table des matières"
    appendix-style: plain
  pdf:
    toc: true
    number-sections: true
    colorlinks: true
    #cite-method: biblatex # HERE: Commented because I do not have biber installed.
    toc-depth: 4
    toc-title: "Table des matières"
    appendix-style: plain
    fontsize: "12"
    linestretch: "1.5"
  docx:
    toc: true
    number-sections: true
    toc-title: "Table des matières"
    highlight-style: github
    toc-depth: 4
    appendix-style: plain
    #reference-doc: template.docx # HERE: Commented because I do not have `template.docx`
editor: source

#bibliography: ["BIBLIO.bib", "references.bib"] # HERE: Commented because I do not have these files.
link-citations: true
link-bibliography: true
#csl: "nature.csl" # HERE: Commented because I do not have `nature.csl`

crossref: 
  labels: roman

filters:
  - acronyms
# HERE: Removed duplicate keys `date`, `editor`, and `bibliography` (YAML error)
acronyms:
  loa_title: ''
  insert_loa: false
  insert_unused: true
  insert_link: true
  #loa_format: '`- **{shortname}**: {longname}`{=raw}'
  loa_format: '`**{shortname}**: {longname}`{=raw}'
  keys:
    - shortname: BM
      longname: Biomarqueur
    - shortname: ADN
      longname: "Acide Désoxyribonucléique"
    # (Rest omitted for brevity but present in my file...)
---

Using the bullet-list format gives similar results.

PierreSolomon commented 4 months ago

Hello,

Now it seem to work. Maybe because of the quarto version (I did go back a few time between the current 1.4.553 current release and the latest pre-release). Currently using the 1.4.553 version.