How do I convert markdown equations to pdf using pandoc - pdf

I have a markdown document with lots of equations (mathjax I think) which renders fine with the application Marked 2. When I try to convert it to pdf with pandoc to create the bibliography, I get an error.
For example, with
\\[ \mu_{s,h,d,y} = \left\{
\begin{array}{1 1}
\omega_{s,h,d,y} + \delta_{s}(t_{s,h,d-1,y} - \omega_{s,h,d-1,y}) & \quad \text{for $t_{s,h,d-1,y}$ is real} \\
\omega_{s,h,d,y} & \quad \text{for $t_{s,h,d-1,y}$ is not real}
\end{array} \right.
\\]
It looks like
However, when I run
pandoc -H format.sty -V fontsize=12pt --bibliography northeast_temperature_refs.bib --csl=american-geophysical-union.csl northeast_temperature_ms2.md -o northeast_temperature_ms.pdf --mathjax
with or without --mathjax I get the following error
! Missing $ inserted.
<inserted text>
$
l.268 \textbackslash{}{[} \mu
pandoc: Error producing PDF from TeX source
If I try to use $$ instead of \\[ like:
$$
\mu_{s,h,d,y} = \left\{
\begin{array}
\omega_{s,h,d,y} + \delta_{s}(t_{s,h,d-1,y} - \omega_{s,h,d-1,y}) & \quad \text{for $$t_{s,h,d-1,y}$$ is real} \\
\omega_{s,h,d,y} & \quad \text{for $$t_{s,h,d-1,y}$$ is not real}
\end{array} \right.
$$
I get the following error:
! LaTeX Error: Illegal character in array arg.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.278 \begin{array}{1 1}
pandoc: Error producing PDF from TeX source
This is my first time ever trying to write equations outside a canned program so any help would be appreciated. I thought I was doing such a good job when I did quick checks with Marked but apparently it doesn't work with pandoc the way I have it.
I am on a Mac with Yosemite and have MacTex installed.

Marked uses a different markdown processor under the hood (MultiMarkdown) than Pandoc, which has different syntax for equations (\\[ \\] instead of $$). If you want to write in a single format for both Marked previewing/HTML and pandoc PDF/anything else output, you can change Marked's processor to Pandoc (directions here). This way you can use $$ syntax for everything.

I think that pandoc doesn't cover the array command, as your command doesn't work for me in an IPython notebook. However, replacing the array command with a cases statement does work for me:
\\[ \mu_{s,h,d,y} = \begin{cases}
\omega_{s,h,d,y} + \delta_{s}(t_{s,h,d-1,y} - \omega_{s,h,d-1,y}) & \quad \text{for $t_{s,h,d-1,y}$ is real} \\
\omega_{s,h,d,y} & \quad \text{for $t_{s,h,d-1,y}$ is not real}
\end{cases}
\\]

Related

gnuplot 'set title' with sprintf : representing angle in terms of fractions of pi

I'd like to run a gnuplot .inp file so all the angles in the script show up automatically in the title as fractions based on the Greek letter pi - instead of a decimal form for the angle. I already know how to use {/Symbol p}, but that is a manual intervention that is impractical in this case.
I have an example sprintf line in a gnuplot input file which can produce nice title information :
angle=( (3*pi) /4 )
set title sprintf ("the angle is %g radians", angle)
plot sin(x)
... the output file (e.g. svg) or terminal (e.g. wxt) shows "2.35619", which is correct, however ; it would be nice to see the Greek letter for pi and the fraction itself, as is typically read off of a polar plot, e.g " 3/4 pi". Likewise for more complex or interesting representations of pi, such as "square root of two over two".
I already know I can manually go into the file and type in by hand "3{/Symbol p}/4", but this needs to be done automatically, because the actual title I am working with has numerous instances of pi showing up as a result of a setting of an angle.
I tried searching for examples of gnuplot being used with sprintf to produce the format of the angle I am interested in, and could not find anything. I am not aware of sprintf being capable of this. So if this is in fact impossible with gnuplot and sprintf, it will be helpful to know. Any tips on what to try next appreciated.
UPDATE: not a solution, but very interesting, might help :
use sprintf after the 'plot' to set the title that appears in the key (but not the overall title):
gnuplot setting line titles by variables
so for example here, the idea would be :
foo=20
plot sin(x)+foo t sprintf ("The angle is set to %g", foo)```
Here is an attempt to define a function to find fractions of Pi.
Basically, sum (check help sum) is used to find suitable multiples/fractions of Pi within a certain tolerance (here: 0.0001). It is "tested" until a denominator of 32. If no integer number is found, the number itself is returned.
In principle, the function could be extended to find multiples or fractions of roots, sqrt(2) or sqrt(3), etc.
This approach can certainly be improved, maybe there are smarter solutions.
Script:
### format number as multiple of pi
reset session
$Data <<EOD
1.5707963267949
-1.5707963267949
6.28318530717959
2.35619449019234
2.0943951023932
-0.98174770424681
2.24399475256414
1.0
1.04
1.047
1.0471
1.04719
EOD
set xrange[-10:10]
set yrange[:] reverse
set offset 0.25,0.25,0.25,0.25
set key noautotitle
dx = 0.0001
fPi(x) = (_x=x/pi, _p=sprintf("%g",x), _d=NaN, sum [_i=1:32] \
(_d!=_d && (abs(_x*_i - floor(_x*_i+dx)) < dx) ? \
(_n=floor(_x*_i+dx),_d=_i, \
_p=sprintf("%sπ%s",abs(_n)==1?_n<0?'-':'':sprintf("%d",_n),\
abs(_d)==1 ? '' : sprintf("/%d",_d)),0) : 0 ), _p)
plot $Data u (0):0:(fPi($1)) w labels font "Times New Roman, 16"
### end of script
Result:
I have [1] a workaround below that might be feasible, and [2] apparently what I was looking for below that (I am writing this in haste). I will mark the question "answered" anyway. To avoid reproducing theozh's script, I offer :
[1]:
add three lines to theozh's script - ideally, immediately before the 'plot' command :
set title sprintf ("Test: %g $\\sqrt{\\pi \\pi \\pi \\pi}$", pi)
set terminal tikz standalone
set output 'gnuplot_test.tex'
one can observe a little testing going on with nonsensical expressions of pi - it is just to see the vinculum extend, and this is a hasty thing - and the double-escapes - they appear to have made it to Stack Overflow correctly.
change the 'plot' line to remove the Times Roman part, but this might not be necessary :
plot $Data u (0):0:(fPi($1)) w labels
importantly, edit gnuplot_test.tex so an \end{document} is on the last line.
run 'pdflatex gnuplot_test.tex'.
This should help move things along - it appears the best approach is to go into the LaTeX world for this - thanks. I tried cairolatex pdf and eps but I was very confused with the LaTeX output. the tikz works almost perfectly.
[2]: What I was looking for : put this below the fPi(x) expression in gnuplot :
set title sprintf ("Testing : \n wxt terminal : \
%g %s %s %s \n tikz output : $\\sqrt{\\pi \\pi \\pi \\pi}$", \
pi, fPi(myAngle01), fPi(myAngle02), fPi(myAngle03) )
# set terminal tikz standalone
# set output 'gnuplot_test.tex'
plot $Data u (0):0:(fPi($1)) w labels t sprintf ("{/Symbol p}= %g, %s, %s, %s, %s", \
pi, fPi(pi), fPi(myAngle01), fPi(myAngle02), fPi(myAngle03) )
... the wxt terminal displays the angles as fractions of pi. I didn't test the output in the LaTeX pipeline - remove if undesired. I think the gnuplot script has to be written for the terminal or output desired - but at least the values can be computed - instead of writing them in "manually".

unsupported format character error in youtube-dl

i've been trying to download a youtube playlist using youtube-dl, but i had a problem in the output template, i used the following command to get the playlist downloaded in an organised way :
youtube-dl -f mp4 -o "Desktop/mainFolder/courses/%(playlist_title)s-%(playlist_uploader)/%(title)s.%(ext)s" --embed-thumbnail --add-metadata --mark-watched https://www.youtube.com/playlist?list=PLzH6n4zXuckpfMu_4Ff8E7Z1behQks5ba
but i kept getting the following error :
ERROR: Error in output template: unsupported format character '/' (0x2f) at index 66 (encoding: 'UTF-8')
it states that i used an unsupported character which is '/', weirdly enough i used almost the same output template format in a previous download which is :
youtube-dl -f mp4 -o "Desktop/mainFolder/courses/%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" --add-metadata https://www.youtube.com/playlist?list=PL4C9296DF81B9EF13
and it worked just fine.
what did i did differently here so that the first command didn't work but the last one did ??
If you see this error it probably means one of the format expressions doesn't end with an s.
In this case, it looks like you're missing one after (playlist_uploader).
youtube-dl -f mp4 -o "Desktop/mainFolder/courses/%(playlist_title)s-%(playlist_uploader)s/%(title)s.%(ext)s" --embed-thumbnail --add-metadata --mark-watched https://www.youtube.com/playlist?list=PLzH6n4zXuckpfMu_4Ff8E7Z1behQks5ba

How to write a text prompt in Nim that has readline-style line editing?

readLine() doesn't support line editing and recalling previous commands, eg:
while true:
var name: string = readLine(stdin)
echo "Hi, ", name, "!"
Has no editing. But if I compile that and wrap it in rlwrap:
$ rlwrap read_test
It works as I hope. with editable and recallable lines, provided by the readline library.
readLineFromStdin() almost works, but doesn't support ctrl+d, it returns an empty string on ctrl+d, which is indistinguishable from a newline.
How can I do this in pure Nim? Thanks!
Ctrl+D is an EOF "signal", and thus you can catch the EOF in your input:
while not endOfFile(stdin):
var name: string = readLine(stdin)
echo "Hi, ", name, "!"
The procedure readLineFromStdin (https://github.com/nim-lang/Nim/blob/version-1-2/lib/impure/rdstdin.nim#L54) is not that complex, and you can re-write your own adding the above code to it.
While #xbello's answer is correct, if you want to use a package, we ended up using https://github.com/jangko/nim-noise, which supports C-d handling and loads of other features.

nomencl latex won't show output

\documentclass[9pt,conference,a4paper,twocolumn]{IEEEtran}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{float}
\usepackage{lscape}
\usepackage{titlesec}
\usepackage{nomencl}
\makenomenclature
\begin{document}
\nomenclature{$k$}{set of hourly intervals}
\printnomenclature
\end{document}
I am trying to run this nomenclature code using TexStudio. I get error everytime, even if I already specified the makeindex as what I read from other reviews.
Here is what I specified:
makeindex (arb).nlo -s nomencl.ist -o (arb).nls
NOTE: where arb is the filename of my tex.
Everytime I ran the code, there are no errors. However, when I check via TOOLS/INDEX ,the errors are:
Process started: makeindex (arb).nlo -s nomencl.ist -o (arb).nls
Input index file (arb).nlo not found. Usage: makeindex [-ilqrcgLT] [-s sty]
[-o ind] [-t log] [-p num] [idx0 idx1 ...]
Process exited with error(s)
THANKS hopefully for the help
The titlesec package does not work in combination with the IEEEtran document class. During compilation it causes the error Undefined control sequence. \ttl#extract\subparagraph. Without an successfully tex run first, makeindex will not have the necessary information to create the index.
Once this problem is fixed, the nomenclatur can be generated with
makeindex ⟨filename⟩.nlo -s nomencl.ist -o ⟨filename⟩.nls
\documentclass[9pt,conference,a4paper,twocolumn]{IEEEtran}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{float}
\usepackage{lscape}
%\usepackage{titlesec}
\usepackage{nomencl}
\makenomenclature
\begin{document}
test
\nomenclature{$k$}{set of hourly intervals}
\nomenclature{$d$}{set of daily intervals}
\printnomenclature
\end{document}
makeindex %.nlo -s nomencl.ist -o %.nls -t %.nlg
I have somehow solve this problem after various tries, I change the index which is above and it ran smoothly without errors in TeXStudio even if titlesec package is use.
NOTE: To add multiple nomenclatures, every time you encode the nomenclature, test index via Tools then RUN. it will solve the mentioned problems.

GVim not recognizing commands in plugin

How do I get gvim to recognize sqlcomplete.vim commands?
I'm unable to use the sqlcomplete.vim plugin. When running :version I get the following output:
and scrolling all the way to the bottom here is the rest of the output:
and the env variables:
:echo $VIM
c:\users\me\.babun\cygwin\etc\
:echo $HOME
H:\
Here is the output of :scriptnames:
When running the sqlcomplete.vim command such as :SQLSetType sqlanywhere the output I get is:
How do I get gvim to recognize sqlcomplete.vim commands?
Another piece of helpful information is the output of :echo &rtp :
H:\vimfiles,H:\.vim\bundle\Vundle.vim,H:\.vim\bundle\dbext.vim,H:\.vim\bundle\SQ
LComplete.vim,C:\Users\me\.babun\cygwin\etc\vimfiles,C:\Users\me\.babu
n\cygwin\etc\,C:\Users\me\.babun\cygwin\etc\vimfiles/after,H:\vimfiles/afte
r,H:\.vim/bundle/Vundle.vim,H:\.vim\bundle\Vundle.vim/after,H:\.vim\bundle\dbext
.vim/after,H:\.vim\bundle\SQLComplete.vim/after
Some points you could check:
:scriptnames shows plugin\sqlcomplete.vim
But the link you provided points to .../vim/runtime/autoload/sqlcomplete.vim, there is no .../vim/runtime/plugin/sqlcomplete.vim, and the version at vim.org also doesn't contains a /plugin file:
install details
Copy sqlcomplete.vim to:
.vim/autoload/sqlcomplete.vim (Unix)
vimfiles\autoload\sqlcomplete.vim (Windows)
For documentation:
:h sql.txt
Maybe you have installed it incorrectly.
The file on your link has version 12 at its header, while the latest version is 15. Try updating to the latest version
Note that this plugin does not define the SQLSetType command.
You could check that by simple searching the file the on link. And on its header:
" Vim OMNI completion script for SQL
" Language: SQL
" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
" Version: 15.0
" Last Change: 2013 May 13
" Homepage: http://www.vim.org/scripts/script.php?script_id=1572
" Usage: For detailed help
" ":help sql.txt"
" or ":help ft-sql-omni"
" or read $VIMRUNTIME/doc/sql.txt
Following :help sql.txt:
2.1 SQLSetType *sqlsettype* *SQLSetType*
--------------
For the people that work with many different databases, it is nice to be
able to flip between the various vendors rules (indent, syntax) on a per
buffer basis, at any time. The ftplugin/sql.vim file defines this function: >
SQLSetType
And scriptnames is not listing ftplugin/sql.vim