In [1]:
NB. show J kernel version
9!:14 ''
In [2]:
NB. load JOD in a clear base locale
load 'general/jod' [ clear ''
NB. The distributed JOD profile automatically RESETME's.
NB. To safely use dictionaries with many J tasks they must
NB. be READONLY. To prevent opening the same put dictionary
NB. READWRITE comment out (dpset) and restart this notebook.
dpset 'RESETME'
NB. Converting Jupyter notebooks to LaTeX is
NB. simplified by ASCII box characters.
portchars ''
NB. Verb to show large boxed displays in
NB. the notebook without ugly wrapping.
sbx_ijod_=: ' ... ' ,"1~ 75&{."1@":
In [3]:
NB. install J addons with command-line pacman
load 'pacman' NB. load pacman jpkg services
In [4]:
'help' jpkg '' NB. what can you do for me?
In [5]:
NB. install all addons
NB. see https://code.jsoftware.com/wiki/Pacman
NB. uncomment next line if addons not installed
NB. 'install' jpkg '*' NB.
In [6]:
3 {. 'showinstalled' jpkg '' NB. first few installed addons
In [7]:
'showupgrade' jpkg '' NB. list addon updates
In [8]:
require 'general/jod'
In [9]:
NB. set a JODroot user folder
NB. if not set /jod/ is the default
NB. use paths for your OS
UserFolders_j_=: UserFolders_j_ , 'JODroot';'c:/temp'
NB. show added folder
UserFolders_j_ {~ (0 {"1 UserFolders_j_) i. <'JODroot'
In [10]:
NB. load JOD developement dictionaries
load_dev_tmp=: 3 : 0
if. +./ (;:'joddev jod utils') e. od '' do.
'dev dictionaries exist'
else.
0!:0<jpath'~addons/general/jodsource/jodsourcesetup.ijs'
end.
)
load_dev_tmp 0
In [11]:
NB. joddev, jod, utils should exist
erase 'load_dev_tmp'
(;:'joddev jod utils') e. od ''
In [12]:
NB. show pandoc version from J - make sure you are running
NB. a recent version of pandoc. There may be different
NB. versions in many locations on various systems.
ppath=: '"C:\Program Files\Pandoc\pandoc"'
THISPANDOC_ajodliterate_=: ppath
shell THISPANDOC_ajodliterate_,' --version'
In [13]:
NB. make sure your version of pandoc
NB. supports J syntax-highlighting
NB. appends line feed character if necessary
tlf=:] , ((10{a.)"_ = {:) }. (10{a.)"_
NB. J is on the supported languages list
pcmd=: THISPANDOC_ajodliterate_,' --list-highlight-languages'
(<;._2 tlf (shell pcmd) -. CR) e.~ <,'j'
In [14]:
require 'general/jod'
NB. open dictionaries
od ;:'joddev jod utils' [ 3 od ''
In [15]:
NB. generate jodliterate
sbx mls 'jodliterate'
In [16]:
NB. load generated script
load 'jodliterate'
In [17]:
require 'general/jod'
od 'utils' [ 3 od ''
In [18]:
NB. display short explanations for (sunmoon) words
sbx hlpnl }. grp 'sunmoon'
In [19]:
NB. display part of the (sunmoon) group document header
NB. this is pandoc compatible markdown - note the LaTeX
NB. commands - pandoc allows markdown/LaTeX mixtures
900 {. 2 9 disp 'sunmoon'
In [20]:
NB. run jodliterate on (sunmoon)
require 'jodliterate'
NB. set the output directory - when
NB. running in Jupyter use a subdirectory
NB. of your notebook directory.
ltxpath=: 'C:\Users\john\AnacondaProjects\testfolder\grplit\'
setjodliterate ltxpath
In [21]:
NB. (grplit) returns a list of generated
NB. LaTeX and command files. The *.bat
NB. file compiles the generated LaTeX
,. grplit 'sunmoon'
In [22]:
_250 {. shell ltxpath,'sunmoon.bat'
In [23]:
NB. uncomment to display generated PDF
NB. shell ltxpath,'sunmoon.pdf'
In [24]:
NB. create a demo dictionary - (didnum) insures new name
require 'general/jod'
NB. new dictionary in default JOD directory
sbx newd itslit_ijod_=: 'aaa',":didnum_ajod_ ''
In [25]:
NB. 1 if new dictionary created
(<itslit) e. od ''
In [26]:
od itslit [ 3 od '' NB. open only new dictionary
In [27]:
NB. define some words
freq=:~. ; #/.~
movmean=:-@[ (+/ % #)\ ]
geomean=:# %: */
bmi=: 704.5"_ * ] % [: *: [
polyprod=:+//.@(*/)
wlst=: ;:'freq movmean geomean bmi polyprod'
NB. put in dictionary
put wlst
NB. short word explanations
t=: ,: 'freq';'frequency distribution'
t=: t , 'movmean';'moving mean'
t=: t , 'geomean';'geometric mean of a list'
t=: t , 'bmi';'body mass index - (x) inches (y) lbs'
t=: t , 'polyprod';'polynomial product'
0 8 put t
In [28]:
NB. make header and macro groups
grp 'litheader' ; wlst
grp 'litmacro' ; wlst
In [29]:
IFACEWORDSlitheader=: wlst
put 'IFACEWORDSlitheader'
In [30]:
NB. add group header markdown
litheader=: (0 : 0)
`litheader` is a markdown demo group.
This markdown text will be
[transmogrified](https://calvinandhobbes.fandom.com)
by `pandoc` to \LaTeX. A group interface will be
generated from the `IFACEWORDSlitheader`
list. Interface lists are usually, but
not always, associated with a *class group*.
\subsection{\texttt{litheader} Interface}
`{~{insert_interface_md_}~}`
)
NB. store markdown as a JOD group document
2 9 put 'litheader';litheader
In [31]:
NB. run jodliterate on group
ltxpath=: 'C:\Users\john\AnacondaProjects\testfolder\grplit\'
setjodliterate ltxpath
{: grplit 'litheader'
In [32]:
NB. compile latex
_250 {. shell ltxpath,'litheader.bat'
In [33]:
NB. uncomment to show PDF
NB. shell ltxpath,'litheader.pdf'
In [34]:
NB. add a LaTeX overview - this code will not
NB. be altered by jodliterate the suffix
NB. '_oview_tex' is required to associate
NB. the overview with the group 'litmacro'
litmacro_oview_tex=: (0 : 0)
This \LaTeX\ code will not be
touched by \texttt{jodliterate}.
\subsection{Business Babel}
``Truth management is enabled.''
\emph{Excerpt from an actual business document!}
Obviously composed in an irony free zone.
\subsection{Some Complicated \LaTeX}
\medskip
\[
\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =
1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
{1+\frac{e^{-8\pi}} {1+\ldots} } } }
\]
)
NB. store LaTeX as JOD text macro
4 put 'litmacro_oview_tex';LATEX_ajod_;litmacro_oview_tex
In [35]:
NB. run jodliterate on group
{: grplit 'litmacro'
In [36]:
NB. compile latex
_250 {. shell ltxpath,'litmacro.bat'
In [37]:
NB. display PDF
NB. shell ltxpath,'litmacro.pdf'
In [38]:
od ;:'joddev jod utils' [ 3 od ''
NB. list macros with substring 'latex'
4 2 dnl 'latex'
In [39]:
NB. display start of macro that
NB. applies jodliterate to JOD code
250 {. 4 disp 'buildjodlatex'
WordPress conversion from UsingJodliterate.ipynb by nb2wp v0.3.1
2 thoughts on “Using jodliterate”