\newcommand{name}[num]{definition}
"Basically the command requires two arguments: the name of the command you want to create, and the definition of the command" . I played with LaTeX and wrote the following three commands:Embedding a remote picture
The following LaTeX document defines a new command "\remoteimage". It takes 3 parameters: a filename, a URL and some parameters for \includegraphics. If the file doesn't exist, the url is downloaded and saved in 'file'. The downloaded image is then included in the final LaTeX document.Note: latex files must be compiled with --enable-write18 to enable system-calls.
pdflatex --enable-write18 input.tex
Result:External Image /Latex by lindenb
GraphViz Dot
The second LaTex Document works the same way. It defines a command "\graphviz" , sends the content of the 2nd argument to graphviz dot and save the resulting image before importing it into the LaTeX document.Result:
Pubmed
The last command define "\pmid" . It needs one Pubmed identifer. It downloads the XML record for this pmid, transforms it to LaTeX with xsltproc and the following XSLT stylesheet:The LaTeX document includes four pubmed identifiers:
Result:
That's it,
Pierre
Nice hacks!
ReplyDelete