From 325250e2645757edfa1445e96423d5e16d17b8fb Mon Sep 17 00:00:00 2001 From: niuyazhe Date: Wed, 16 Feb 2022 16:19:12 +0800 Subject: [PATCH 1/4] config(nyz): support latex in rst --- source/conf.py | 21 +++++++++++++++++++++ source/hands_on/ddpg.rst | 7 ------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/source/conf.py b/source/conf.py index d791b60c..6debe413 100644 --- a/source/conf.py +++ b/source/conf.py @@ -49,8 +49,29 @@ 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', + 'sphinx.ext.imgmath', 'enum_tools.autoenum' ] +imgmath_image_format = 'svg' +imgmath_font_size = 14 +imgmath_latex_preamble = r''' +\usepackage{algorithm} +\usepackage{algorithmic} +\usepackage{amsmath} +\usepackage{cancel} +\usepackage[verbose=true,letterpaper]{geometry} +\geometry{ + textheight=12in, + textwidth=6.5in, + top=1in, + headheight=12pt, + headsep=25pt, + footskip=30pt + } +\newcommand{\E}{{\mathrm E}} +\newcommand{\underE}[2]{\underset{\begin{subarray}{c}#1 \end{subarray}}{\E}\left[ #2 \right]} +\newcommand{\Epi}[1]{\underset{\begin{subarray}{c}\tau \sim \pi \end{subarray}}{\E}\left[ #1 \right]} +''' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/source/hands_on/ddpg.rst b/source/hands_on/ddpg.rst index 8f0d4558..69b36604 100644 --- a/source/hands_on/ddpg.rst +++ b/source/hands_on/ddpg.rst @@ -47,7 +47,6 @@ Pseudocode ---------- .. math:: - :nowrap: \begin{algorithm}[H] @@ -88,12 +87,6 @@ Pseudocode \end{algorithmic} \end{algorithm} - -.. image:: - images/DDPG.jpg - :scale: 75% - :align: center - Extensions ----------- DDPG can be combined with: From cd3c652e6b01e6ddc7c3a9f34be2412d62954f4f Mon Sep 17 00:00:00 2001 From: niuyazhe Date: Wed, 16 Feb 2022 16:19:12 +0800 Subject: [PATCH 2/4] config(nyz): support latex in rst --- source/12_policies/ddpg.rst | 7 ------- source/conf.py | 29 +++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/source/12_policies/ddpg.rst b/source/12_policies/ddpg.rst index 8b110235..ec3401f5 100644 --- a/source/12_policies/ddpg.rst +++ b/source/12_policies/ddpg.rst @@ -47,7 +47,6 @@ Pseudocode ---------- .. math:: - :nowrap: \begin{algorithm}[H] @@ -88,12 +87,6 @@ Pseudocode \end{algorithmic} \end{algorithm} - -.. image:: - images/DDPG.jpg - :scale: 75% - :align: center - Extensions ----------- DDPG can be combined with: diff --git a/source/conf.py b/source/conf.py index cc1d1748..cdcef748 100644 --- a/source/conf.py +++ b/source/conf.py @@ -43,10 +43,35 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.mathjax', - 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.mathjax', + 'sphinx.ext.ifconfig', + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', + 'sphinx.ext.imgmath', 'enum_tools.autoenum' ] +imgmath_image_format = 'svg' +imgmath_font_size = 14 +imgmath_latex_preamble = r''' +\usepackage{algorithm} +\usepackage{algorithmic} +\usepackage{amsmath} +\usepackage{cancel} +\usepackage[verbose=true,letterpaper]{geometry} +\geometry{ + textheight=12in, + textwidth=6.5in, + top=1in, + headheight=12pt, + headsep=25pt, + footskip=30pt + } +\newcommand{\E}{{\mathrm E}} +\newcommand{\underE}[2]{\underset{\begin{subarray}{c}#1 \end{subarray}}{\E}\left[ #2 \right]} +\newcommand{\Epi}[1]{\underset{\begin{subarray}{c}\tau \sim \pi \end{subarray}}{\E}\left[ #1 \right]} +''' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] From b21e51cb6e775f9e0607a92978c2e721ed3cc3a5 Mon Sep 17 00:00:00 2001 From: zhaoliangxuan Date: Fri, 29 Jul 2022 10:20:38 +0800 Subject: [PATCH 3/4] fixbug(zlx): can display psuedo-code correctly now --- source/conf.py | 65 ++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/source/conf.py b/source/conf.py index cdcef748..8e16f2af 100644 --- a/source/conf.py +++ b/source/conf.py @@ -45,33 +45,14 @@ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', - 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', 'sphinx.ext.imgmath', - 'enum_tools.autoenum' + # 'sphinx.ext.mathjax', # can only use one of imgmath and mathjax + 'enum_tools.autoenum', + # 'sphinxcontrib.pseudocode', ] -imgmath_image_format = 'svg' -imgmath_font_size = 14 -imgmath_latex_preamble = r''' -\usepackage{algorithm} -\usepackage{algorithmic} -\usepackage{amsmath} -\usepackage{cancel} -\usepackage[verbose=true,letterpaper]{geometry} -\geometry{ - textheight=12in, - textwidth=6.5in, - top=1in, - headheight=12pt, - headsep=25pt, - footskip=30pt - } -\newcommand{\E}{{\mathrm E}} -\newcommand{\underE}[2]{\underset{\begin{subarray}{c}#1 \end{subarray}}{\E}\left[ #2 \right]} -\newcommand{\Epi}[1]{\underset{\begin{subarray}{c}\tau \sim \pi \end{subarray}}{\E}\left[ #1 \right]} -''' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -132,23 +113,51 @@ # Output file base name for HTML help builder. htmlhelp_basename = 'DI-enginedoc' -# -- Options for LaTeX output ------------------------------------------------ +# -- Options for LaTeX output (+ image type math) ------------------------------------------------ + +# imgmath settings +imgmath_image_format = 'svg' +imgmath_font_size = 14 + +imgmath_latex_preamble = r''' + \usepackage{algorithm} + \usepackage{algorithmic} + \usepackage{amsmath} + \usepackage{cancel} + \usepackage[verbose=true,letterpaper]{geometry} + \geometry{ + textheight=12in, + textwidth=6.5in, + top=1in, + headheight=12pt, + headsep=25pt, + footskip=30pt + } + \newcommand{\E}{{\mathrm E}} + \newcommand{\underE}[2]{\underset{\begin{subarray}{c}#1 \end{subarray}}{\E}\left[ #2 \right]} + \newcommand{\Epi}[1]{\underset{\begin{subarray}{c}\tau \sim \pi \end{subarray}}{\E}\left[ #1 \right]} +''' latex_elements = { # The paper size ('letterpaper' or 'a4paper'). - # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). - # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', + 'preamble': + r''' + \usepackage{algorithm} + \usepackage{algorithmic} + \usepackage{amsmath} + \usepackage{cancel} + \newcommand{\E}{{\mathrm E}} + \newcommand{\underE}[2]{\underset{\begin{subarray}{c}#1 \end{subarray}}{\E}\left[ #2 \right]} + \newcommand{\Epi}[1]{\underset{\begin{subarray}{c}\tau \sim \pi \end{subarray}}{\E}\left[ #1 \right]} + ''', # Latex figure (float) alignment - # # 'figure_align': 'htbp', } From ad26b90b218bb9a1e43c1f29a7c59812fb048034 Mon Sep 17 00:00:00 2001 From: zhaoliangxuan Date: Mon, 1 Aug 2022 18:48:42 +0800 Subject: [PATCH 4/4] polish(zlx): make img-type math pic use minimal conf, delete useless parts --- source/conf.py | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/source/conf.py b/source/conf.py index d9113a3e..1e3e6c89 100644 --- a/source/conf.py +++ b/source/conf.py @@ -51,28 +51,7 @@ 'sphinx.ext.imgmath', # 'sphinx.ext.mathjax', # can only use one of imgmath and mathjax 'enum_tools.autoenum', - # 'sphinxcontrib.pseudocode', ] -imgmath_image_format = 'svg' -imgmath_font_size = 14 -imgmath_latex_preamble = r''' -\usepackage{algorithm} -\usepackage{algorithmic} -\usepackage{amsmath} -\usepackage{cancel} -\usepackage[verbose=true,letterpaper]{geometry} -\geometry{ - textheight=12in, - textwidth=6.5in, - top=1in, - headheight=12pt, - headsep=25pt, - footskip=30pt - } -\newcommand{\E}{{\mathrm E}} -\newcommand{\underE}[2]{\underset{\begin{subarray}{c}#1 \end{subarray}}{\E}\left[ #2 \right]} -\newcommand{\Epi}[1]{\underset{\begin{subarray}{c}\tau \sim \pi \end{subarray}}{\E}\left[ #1 \right]} -''' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -133,7 +112,7 @@ # Output file base name for HTML help builder. htmlhelp_basename = 'DI-enginedoc' -# -- Options for LaTeX output (+ image type math) ------------------------------------------------ +# -- Options for LaTeX output + image type math ------------------------------------------------ # imgmath settings imgmath_image_format = 'svg' @@ -166,16 +145,7 @@ # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. - 'preamble': - r''' - \usepackage{algorithm} - \usepackage{algorithmic} - \usepackage{amsmath} - \usepackage{cancel} - \newcommand{\E}{{\mathrm E}} - \newcommand{\underE}[2]{\underset{\begin{subarray}{c}#1 \end{subarray}}{\E}\left[ #2 \right]} - \newcommand{\Epi}[1]{\underset{\begin{subarray}{c}\tau \sim \pi \end{subarray}}{\E}\left[ #1 \right]} - ''', + # 'preamble': '', # Latex figure (float) alignment # 'figure_align': 'htbp', @@ -184,9 +154,9 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'DI-engine.tex', 'DI-engine Documentation', 'bao', 'manual'), -] +# latex_documents = [ +# (master_doc, 'DI-engine.tex', 'DI-engine Documentation', 'bao', 'manual'), +# ] # -- Options for manual page output ------------------------------------------