cameronbracken / pgfSweave

Quality graphics and speedy compilation with Sweave
http://r-forge.r-project.org/projects/pgfsweave/
29 stars 6 forks source link

Options to customize highlighted output #21

Open baptiste opened 13 years ago

baptiste commented 13 years ago

It would be nice to have the same option to surround the source code with a frame as in the highlight package. Possible niceties would include settings for

The LaTeX package listings [*] could be useful for these (and more) options; however I don't know if it can play well with external highlighting.

[*] ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/listings/listings.pdf

cameronbracken commented 13 years ago

Changing the name of this issue to a more general feature.

In general it would also be nice to have options to customize highlighted output. Currently there is no easy way to customize highlighted output (such as different colors and backgrounds).

mlt commented 12 years ago

I'd like also to be able to change font size as R code eats space on the page

cameronbracken commented 12 years ago

So I basically found out you cant really customize the color output, but You can change the font size currently by editing the Hinput environment.

mlt commented 12 years ago

I don't see any Hinput in output tex file generated. I'm using 1.2.1 version. Did you mean Houtput? So if I define mine, pgfSweave won't insert the following by itself?

\newenvironment{Houtput}{\raggedright}{% % }

cameronbracken commented 12 years ago

My bad, in the cran version it is called Houtput but in the Github version it is called Hinput to be consistant with Sweave's Sinput.

pgfSweave will put it in regardless if you have it or not. It will always put the definition below you documentclass command so you can use renewenvironment and you should be safe.

BTW, the dev version devines the environment as:

\newenvironment{Hinput}{\begin{trivlist}\item}{\end{trivlist}}

which can help with some spacing problems. You may want to work off of that.

mlt commented 12 years ago

I confirm that the following after documentclass did the trick with cran version

\renewenvironment{Houtput}{\footnotesize\begin{trivlist}\item}{\end{trivlist}}

Is there an easy way to prevent hanging code so I don't have single line on the next page/column to force LaTeX to keep R chunks on a single page if possible?

cameronbracken commented 12 years ago

Hmm, I dont know an obvious easy way, that will probably require some LaTeX trickery, maybe try re-defining the environment as a float?

mlt commented 12 years ago
\renewenvironment{Houtput}{
  \begin{samepage}
    \footnotesize
    \begin{trivlist}
    \item}
    {\end{trivlist}
  \end{samepage}
}

Did the trick for me.

I'm not sure if it makes sense to add pgfSweave parameter to force certain blocks to be on the same page so it spits samepage environment around the block if defined.

cameronbracken commented 12 years ago

Cool! Yeah, I'm not sure if I would make this the default but that would be a great global option. Thanks for the suggestion.

mlt commented 12 years ago

I didn't ask for defaults :-) I like original approach that used Sweave.sty so all the formatting is defined there instead of being pushed into .tex.

cameronbracken commented 12 years ago

I guess it just a matter of taste ;) I prefer it all be in the .tex file, I think Sweave.sty causes more problems than its worth.

mlt commented 12 years ago

Heh. Yet another idea is not to dump definitions if Sweave.sty is included. I'm not sure about implementation details as I see things changed since I used pgfSweave last time. Anyway, enough for offtopic :-)

mlt commented 12 years ago

I see \hlnormalsizeboxclosebrace, \hltinyboxclosebrace and alike in generated tex file. What option do I use to get tiny size instead of normal in highligthed output? Curly braces and some operators look disproportional when I have highlight=TRUE and change font size by renewing Houtput environment. Is it still work in progress?