Skip to content

Commit

Permalink
Added glossary support
Browse files Browse the repository at this point in the history
  • Loading branch information
TilBlechschmidt committed Sep 29, 2019
1 parent ca0ca34 commit a26193f
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .build/FlagsGeneral.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
--bibliography=src/bibliography.yaml
--csl .template/ieee.csl
--metadata-file=.template/metadata.yml
--lua-filter=.template/date.lua
--lua-filter=.template/pandoc/date.lua
--lua-filter=.template/pandoc/gls.lua
1 change: 1 addition & 0 deletions .build/FlagsPDF.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
--template=.template/tex/template.tex
--include-in-header=.template/tex/packages.tex
--include-in-header=src/glossary.tex
--include-before-body=.template/tex/theme.tex
--include-before-body=.template/tex/layout.tex
--number-sections
Expand Down
1 change: 1 addition & 0 deletions .template/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Deckblatt: true
toc: true
lot: false
lof: false
glossaryafter: true
File renamed without changes.
55 changes: 55 additions & 0 deletions .template/pandoc/gls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
-- Source: https://github.com/tomncooper/pandoc-gls

function replace(front, ac, back, command)

new_str = string.format("%s\\%s{%s}%s", front, command, ac, back)

return new_str
end

function Str(el)

front, capital, plural, ac, apostrophe, back = el.text:match(
"(%g*)%(([%+%-]+)(%^-)(%w+[_%-]*%w*)%)([%\u{0027}%\u{2019}]*)(%g*)"
)

if ac ~= "" then
if plural == "^" then
if capital == "++" then
command = "Glspl"
elseif capital == "+" then
command = "glspl"
elseif capital == "-+" then
command = "Glsentryplural"
elseif capital == "-" then
command = "glsentryplural"
else
-- Unknown command string so just return the element unchanged
return el
end
else
if capital == "++" then
command = "Gls"
elseif capital == "+" then
command = "gls"
elseif capital == "-+" then
command = "Glsentryname"
elseif capital == "-" then
command = "glsentryname"
else
-- Unknown command string so just return the element unchanged
return el
end
end

if apostrophe == "\u{0027}" or apostrophe == "\u{2019}" then
if back ~= "" then
back = string.format("\\textquotesingle %s", back)
else
back = "\\textquotesingle\\space"
end
end

return pandoc.RawInline("tex", replace(front, ac, back, command))
end
end
4 changes: 3 additions & 1 deletion .template/tex/packages.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
\usepackage{fancyhdr}

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{booktabs}

\usepackage{glossaries}
14 changes: 13 additions & 1 deletion .template/tex/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@
$for(header-includes)$
$header-includes$
$endfor$

\makenoidxglossaries

$if(lang)$
\ifnum 0\ifxetex 1\fi=0 % if pdftex or luatex
\usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
Expand Down Expand Up @@ -418,6 +421,11 @@
$include-before$
$endfor$

$if(glossaryafter)$
$else$
\printnoidxglossary[sort=word]
$endif$

$if(toc)$
$if(toc-title)$
\renewcommand*\contentsname{$toc-title$}
Expand Down Expand Up @@ -482,6 +490,10 @@
$endif$
$for(include-after)$
$include-after$

$endfor$

$if(glossaryafter)$
\printnoidxglossary[sort=word]
$endif$

\end{document}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ If you are not a fan of our custom designed, anonymized title page you can remov

You can enable them by adding `lot: true` and `lof: true` respectively in the metadata section.

### Q: What about glossary entries?

Glossary entries are defined in `src/glossary.tex` and you can use them [according to this documentation](https://github.com/tomncooper/pandoc-gls/blob/ed659c7b50baab9ce7c8eab15285fe9602f914f7/ReadMe.md#pandoc-gls)

## Feedback

In case of any issues with the template or feature requests do not hesitate to create an entry on the [issue tracker of the template](https://github.com/TexNAK/Science-Paper-Template/issues).
Expand Down
2 changes: 1 addition & 1 deletion src/01_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
keywords: [keyword1, keyword2]
---

# Possent ventis hanc delubra
# Possent ventis hanc delubra (+CPU)

## Colophonius curvum stetit sospes

Expand Down
7 changes: 7 additions & 0 deletions src/glossary.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\newglossaryentry{CPU}
{
name={Central Processing Unit},
description={the key component of a computer system, which contains the circuitry necessary to interpret and execute program instructions.}
}

\newacronym{BAR}{BAR}{big awesome robot}

0 comments on commit a26193f

Please sign in to comment.