Allow for glossary in texnote. Implies ruuning makeglosaries in latex_tools and changes in template files.

main
Jonathan Grizou 12 years ago
parent 62e3c8e9e4
commit 8524b9d5b8

@ -9,7 +9,7 @@
%} %}
%HEADER{ %HEADER{
%This part is the header, you can modify it as you wish. It will be removed when compiling higher level notes %This part is the header, you can modify it as you wish. It will be removed when compiling higher level notes
%TITLE, AUTHOR, YEAR, ABSTRACT will be automatyically replaced with respect to the associated bibfile thanks to the \autofill{*FIELD*}{} marker. %TITLE, AUTHOR, YEAR, ABSTRACT will be automatically replaced with respect to the associated bibfile thanks to the \autofill{*FIELD*}{} marker.
\begin{center} \begin{center}
\Large{\textbf{\autofill{TITLE}{Title not found}}} \\ [0.2cm] \Large{\textbf{\autofill{TITLE}{Title not found}}} \\ [0.2cm]
\small{\textsc{\autofill{AUTHOR}{Author(s) not found}}} \\ [0.2cm] \small{\textsc{\autofill{AUTHOR}{Author(s) not found}}} \\ [0.2cm]
@ -19,7 +19,7 @@
\autofill{ABSTRACT}{Abstract not found} \autofill{ABSTRACT}{Abstract not found}
\end{abstract} \end{abstract}
%Write your notes below %Write your notes below
%Do not use \section{} or \subsection{} as they may be source of problems when concatenating notes. %Do not use \section{} or \subsection{} as they may be source of problems when concatenating notes. Use \paragraph{} instead.
%} %}
@ -34,5 +34,8 @@
%[texnote] %[texnote]
%bib_style = plain %bib_style = plain
\bibliography{INFO} %The bibliography location is automatically filled \bibliography{INFO} %The bibliography location is automatically filled
%The glossary style is default
\printglossary
%You can add a new glossary entry using \dictentry{'name'}{'description'} (see style file). This will automatically add a new reference and display it in the glossary even if never referenced (using \gls{'name'}).
\end{document} \end{document}
%} %}

@ -1,4 +1,11 @@
%DO_NOT_MODIFY{ %DO_NOT_MODIFY{
%Dummy command used as marker for the autofill %Dummy command used as marker for the autofill
\newcommand{\autofill}[2]{#2} \newcommand{\autofill}[2]{#2}
%command for easy glossary, requires to run: 'makeglossaries filename'
\usepackage[nonumberlist]{glossaries}
\newcommand{\dictentry}[2]{%
\newglossaryentry{#1}{name=#1,description={#2}}%
\glslink{#1}{}%
}
\makeglossaries
%} %}

@ -30,6 +30,7 @@ def full_compile(full_path_to_file, verbose=False):
filename, extension = os.path.splitext(full_path_to_file) filename, extension = os.path.splitext(full_path_to_file)
run_pdflatex(filename, stdout=FNULL) run_pdflatex(filename, stdout=FNULL)
run_bibtex(filename, stdout=FNULL) run_bibtex(filename, stdout=FNULL)
run_makeglossaries(filename, stdout=FNULL)
run_pdflatex(filename, stdout=FNULL, nb_time=3) run_pdflatex(filename, stdout=FNULL, nb_time=3)
@ -50,3 +51,6 @@ def run_pdflatex(full_path_to_file, stdout=None, nb_time=1):
def run_bibtex(full_path_to_file, stdout=None, nb_time=1): def run_bibtex(full_path_to_file, stdout=None, nb_time=1):
run_command('bibtex', full_path_to_file, stdout, nb_time) run_command('bibtex', full_path_to_file, stdout, nb_time)
def run_makeglossaries(full_path_to_file, stdout=None, nb_time=1):
run_command('makeglossaries', full_path_to_file, stdout, nb_time)

@ -125,8 +125,11 @@ class TexnotePlugin(PapersPlugin):
def _texfile(self, citekey): def _texfile(self, citekey):
return os.path.join(DIR, citekey + '.tex') return os.path.join(DIR, citekey + '.tex')
def _exist_texfile(self, citekey):
return files.check_file(self._texfile(citekey))
def _ensure_texfile(self, citekey): def _ensure_texfile(self, citekey):
if not files.check_file(self._texfile(citekey)): if not self._exist_texfile(citekey):
shutil.copy(TPL_BODY, self._texfile(citekey)) shutil.copy(TPL_BODY, self._texfile(citekey))
def get_bib_style(self): def get_bib_style(self):
@ -189,6 +192,12 @@ class TexnotePlugin(PapersPlugin):
os.remove(self.get_texfile(citekey)) os.remove(self.get_texfile(citekey))
def rename(self, old_citekey, new_citekey, overwrite=False): def rename(self, old_citekey, new_citekey, overwrite=False):
if self._exist_texfile(old_citekey):
if not overwrite and self._exist_texfile(new_citekey):
ui = get_ui()
are_you_sure = 'Are you sure you want to delete [{}]'.format(citekey)
sure = ui.input_yn(question=are_you_sure, default='n')
if overwrite or sure:
shutil.move(self.get_texfile(old_citekey), self.get_texfile(new_citekey)) shutil.move(self.get_texfile(old_citekey), self.get_texfile(new_citekey))
def generate_bib(self): def generate_bib(self):

Loading…
Cancel
Save