Does any literate programming environment support on the fly?

I am currently writing many small reports. Most of them are just dumps of values ​​with some graphs and illustrative comments.

Is there a competent programming environment that allows me to write my reports in a convenient format (preferably markdown / latex and haskell), and then is converted to some output format (preferably pdf) that contains the results of the calculations performed in the source file?

I know that Haskell supports literate programming, but I don’t think that the output (and possibly whole images) can be captured.

+6
source share
5 answers

The lhs2TeX preprocessor supports evaluation of Haskell expressions through GHCi. Here is a minimal example:

\documentclass{article} %include polycode.fmt %options ghci \begin{document} Running > fmap (+1) [1..10] yields \eval{fmap (+1) [1..10]}. \end{document} 

This will lead to output of the output that contains the list [2,3,4,5,6,7,8,9,10,11] in the place where the \eval command is in the input line.

You can refer to definitions from the current file. Ie, the \eval function works by loading the current file into ghci and then evaluating the expression in this context.

There is also \perform , which does the same as \eval , but the result will not be considered as part of the Haskell code, but rather as part of the LaTeX code. This way you can write Haskell functions that generate parts of your output.

As the saying goes, there are many things that could be improved in this function in lhs2TeX, and the implementation is pretty gown.

EDIT: To conclude from the comments, the goal is to include images created by the Chart library. Here is a concept document that shows how to achieve this:

 \documentclass{article} \usepackage{graphicx} %include polycode.fmt %options ghci %if style == newcode (Stuff here will not be typeset by LaTeX, but seen by Haskell.) > import Data.Accessor > import Graphics.Rendering.Chart > > renderAndInclude :: Renderable a -> FilePath -> IO () > renderAndInclude r filename = do > renderableToPDFFile r 200 200 filename > putStrLn $ "\\includegraphics{" ++ filename ++ "}" %endif %format ^= = "\mathbin{{}^\wedge\!\!=}" \begin{document} The image description > image :: Renderable () > image = toRenderable > $ layout1_title ^= "Test" > $ layout1_plots ^= [ Left (toPlot plot) ] > $ defaultLayout1 > where > plot = plot_lines_values ^= [[ (x, sin x) | x <- [0, 0.01 .. 10 :: Double] ]] > $ defaultPlotLines yields the following output: \perform{renderAndInclude image "image.pdf"}. \end{document} 

The central helper function you should write is something like renderAndInclude above, which does the actual rendering, writes the result to a file, and issues the LaTeX \includegraphics command, which reads the file.

+15
source

If you don't have to have Haskell, you can get the rest of Sweave and R. Basically you write a LaTeX document with embedded R code. You can include either code, result (including graphics), or both in your final release of the PDF. Knitr is a later extension (or simplification?) Of Sweave.

+3
source

If you want to use charts instead of charts, the chart builder , as described in this blog post, is your friend. Works with markdowns and LaTeX.

+2
source

You can try http://code.google.com/p/nano-lp/ , it supports Markdown / Multimarkdown and other lightweight markups (but also OpenOffice), and it’s easy to include multiple files into one. With OpenOffice, you can export the resulting file to PDF, for example. Asciidoc and TeX / LaTeX are also supported, so you can use them to create PDFs too

0
source

Sorry for being late for the party very late. The answer comes only as a link for future visitors to this question.

Org-mode provides a good, competent programming environment. Although the universe itself is worth a look! More detailed information on the code processing method can be found in the following links:

There is also support for Haskell, otherwise this comment will be redundant. Although the format is not Markdown, Org-mode has a very simple way to markup.

0
source

All Articles