pgfSweave icon indicating copy to clipboard operation
pgfSweave copied to clipboard

Options to customize highlighted output

Open baptiste opened this issue 14 years ago • 13 comments

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 box colour and fill
  • the type of box (U, O, L, ...) and the linetype (single, double)
  • an optional title (as in your vignettes)

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

baptiste avatar Feb 11 '11 06:02 baptiste

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).

cameronbracken avatar Apr 12 '11 22:04 cameronbracken

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

mlt avatar Aug 15 '11 21:08 mlt

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.

cameronbracken avatar Aug 15 '11 21:08 cameronbracken

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}{% % }

mlt avatar Aug 15 '11 21:08 mlt

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.

cameronbracken avatar Aug 15 '11 22:08 cameronbracken

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?

mlt avatar Aug 15 '11 22:08 mlt

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

cameronbracken avatar Aug 15 '11 22:08 cameronbracken

\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.

mlt avatar Aug 15 '11 22:08 mlt

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.

cameronbracken avatar Aug 15 '11 22:08 cameronbracken

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.

mlt avatar Aug 15 '11 22:08 mlt

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.

cameronbracken avatar Aug 15 '11 23:08 cameronbracken

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 avatar Aug 15 '11 23:08 mlt

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?

mlt avatar Sep 12 '11 20:09 mlt