Browse Source

Merge pull request #620 from cbscribe/sphinx_math_test

Add math/formula support in Sphinx
Rémi Verschelde 7 years ago
parent
commit
b9e87f0938
3 changed files with 13 additions and 5 deletions
  1. 5 0
      Makefile
  2. 1 1
      conf.py
  3. 7 4
      learning/features/math/vector_math.rst

+ 5 - 0
Makefile

@@ -6,12 +6,17 @@ SPHINXOPTS    =
 SPHINXBUILD   = sphinx-build
 PAPER         =
 BUILDDIR      = _build
+LATEXDEPS     = latex dvipng
 
 # User-friendly check for sphinx-build
 ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
 $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
 endif
 
+# check for latex dependencies
+E := $(foreach exec, $(LATEXDEPS),\
+	$(if $(shell which $(exec)), some string,$(warning The $(exec) command was not found: math formulas will not be built. LaTeX is required for math formula support. If you don't have LaTeX installed, grab it from https://www.latex-project.org/get/)))
+
 # Internal variables.
 PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter

+ 1 - 1
conf.py

@@ -11,7 +11,7 @@ needs_sphinx = '1.3'
 
 # Sphinx extension module names and templates location
 sys.path.append(os.path.abspath('extensions'))
-extensions = ['gdscript', 'sphinx_tabs.tabs']
+extensions = ['gdscript', 'sphinx_tabs.tabs', 'sphinx.ext.imgmath']
 templates_path = ['_templates']
 
 # You can specify multiple suffix as a list of string: ['.rst', '.md']

+ 7 - 4
learning/features/math/vector_math.rst

@@ -212,14 +212,17 @@ but is often misunderstood. Dot product is an operation on two vectors that
 returns a **scalar**. Unlike a vector, which contains both magnitude and
 direction, a scalar value has only magnitude.
 
-The formula for dot product takes two common
-forms:
+The formula for dot product takes two common forms:
 
-.. image:: img/vector_dot1.png
+.. math::
+    
+    A \cdot B = \left \| A \right \|\left \| B \right \|\cos \Theta
 
 and
 
-.. image:: img/vector_dot2.png
+.. math::
+    
+    A \cdot B = A_{x}B_{x} + A_{y}B_{y}
 
 However, in most cases it is easiest to use the built-in method. Note that
 the order of the two vectors does not matter: