diff --git a/src/latex_envs/__init__.py b/src/latex_envs/__init__.py index 08756b2..8cd7b63 100644 --- a/src/latex_envs/__init__.py +++ b/src/latex_envs/__init__.py @@ -3,7 +3,7 @@ from . import latex_envs -__version__ = '1.4.0' +__version__ = '1.4.1' def _jupyter_nbextension_paths(): diff --git a/src/latex_envs/latex_envs.py b/src/latex_envs/latex_envs.py index 3dbc410..35180f7 100644 --- a/src/latex_envs/latex_envs.py +++ b/src/latex_envs/latex_envs.py @@ -414,6 +414,10 @@ class LenvsLatexExporter(LatexExporter): Exports to a LaTeX document """ + config_title = Bool( + True, help="Proper Title Format").tag(config=True, alias="ct") + config_biblio = Bool( + True, help="Easy Bibliography Formatting").tag(config=True, alias="cb") removeHeaders = Bool( False, help="Remove headers and footers").tag(config=True, alias="rh") figcaptionProcess = Bool( @@ -501,9 +505,26 @@ def tocrefrm(self, text): newtext = re.sub('\\\\begin{verbatim}[\s]*?[\s]*?\\\\end{verbatim}', '', newtext, flags=re.M) # noqa # bottom page with links to Index/back/next (suppress this) # '----[\s]*?
[Index](toc.ipynb)[\S ]*?.ipynb\)
' - newtext = re.sub('\\\\begin{center}\\\\rule{[\S\s]*?\\\\end{center}[\s]*?\S*\href{toc.ipynb}{Index}[\S\s ]*?.ipynb}{Next}', '', newtext, flags=re.M) # noqa + newtext = re.sub('\\\\begin{center}\\\\rule{[\S\s]*?\\\\end{center}[\s]*?\S*\\\\href{toc.ipynb}{Index}[\S\s ]*?.ipynb}{Next}', '', newtext, flags=re.M) # noqa return newtext + def configure_title(self, nb_text): + # get rid of the first \maketitle command which is in the wrong place + nb_text = nb_text.replace('\\maketitle', '', 1) + # replace the second (correctly placed) \maketitle command with itself, and make a TOC (table of contents) on the next line + nb_text = nb_text.replace('\\maketitle', '\\maketitle\n\\tableofcontents', 1) + return nb_text + + def configure_bibliography(self, nb_text): + # enter your bibliography name here + bibliography_name = "math" + # enter your preferred bibliography style here + bibliography_style = "unsrt" + # construct the string which will insert this information into the document + str = '\n\\bibliographystyle{' + bibliography_style + '}\n\\bibliography{' + bibliography_name +'}' + # replace the current generated text (which causes errors) with the desired text + nb_text = nb_text.replace(r'\hypertarget{references}{%', str) + return nb_text def postprocess(self, nb_text): nb_text = nb_text.replace('!nl!', '\n') @@ -524,6 +545,10 @@ def postprocess(self, nb_text): newtext = newtext.replace('\\maketitle', '') newtext = newtext.replace('\\tableofcontents', '') nb_text = newtext + if self.config_title: + nb_text = self.configure_title(nb_text) + if self.config_biblio: + nb_text = self.configure_bibliography(nb_text) if self.tocrefRemove: nb_text = self.tocrefrm(nb_text) return nb_text diff --git a/src/latex_envs/templates/thmsInNb_article.tplx b/src/latex_envs/templates/thmsInNb_article.tplx index 126f655..c75927f 100644 --- a/src/latex_envs/templates/thmsInNb_article.tplx +++ b/src/latex_envs/templates/thmsInNb_article.tplx @@ -7,13 +7,6 @@ ((* block h5 -*))\subparagraph((* endblock h5 -*)) -((* block abstract *)) -\tableofcontents -((* endblock abstract *)) - -%or? -%((* block toc *))\tableofcontents((* endblock toc *)) - %=============================================================================== % My custom output style @@ -38,19 +31,23 @@ %((*- block output_prompt -*)) %((*- endblock output_prompt -*)) - -((* block author *)) -\author{J.-F. Bercher} -((* endblock author *)) - -((* block title *)) -\title{ } -((* endblock title *)) - ((* block packages *)) ((( super() ))) + \usepackage[nottoc,numbib]{tocbibind} % add the bibliography to the TOC \usepackage{listings} % Used to define pretty listings for code sections [jfb] \usepackage{float} + \usepackage{amsthm} + \usepackage{amsmath} + \newtheorem{theorem}{Theorem} + \newtheorem{definition}{Definition} + \newtheorem{proposition}{Proposition} + \newtheorem{lemma}{Lemma} + \newtheorem{corollary}{Corollary} + \newtheorem{property}{Property} + \newtheorem{problem}{Promlem} + \newtheorem{exercise}{Exercise} + \newtheorem{example}{Example} + \newtheorem{remark}{Remark} ((* endblock packages *)) %or -- both work @@ -147,10 +144,12 @@ framesep=10pt, ((* block bibliography *)) -%\bibliographystyle{ieetran} -%\bibliography{Thesis} +% EDIT THE 2 LINES BELOW TO CUSTOMIZE BIBLIOGRAPHY +%\bibliographystyle{unsrt} +%\bibliography{math} ((* endblock bibliography *)) + ((*- block data_png -*)) ((( draw_figure_with_caption(output,'image/png',cell) ))) ((*- endblock -*))