Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New argument to provide additional options to tikzpicture environment #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hbuschme
Copy link

@hbuschme hbuschme commented Aug 25, 2016

The changes in this pull request extend the R-function tikz with a new character string argument pictureOptions that allows for a specification of additional options that are provided to the tikzpicture environment's option list.

This feature results from a personal need of mine. I need the plots from tikzdevice to be typeset in a sans-serif font family. So far I have generated the plots as complete figures and have manually added ,font=\sffamily to the option list of the tikzpicture environment.

Using the new argument it is now possible to add the option from within R

tikz("tikz-example.tex", width = 3.25, height = 3.25, pictureOptions = ",font=\sffamily")
plot(1, 1, main = "Hello \\TeX !")
dev.off()

which then results in the following TikZ/LaTeX code:

    … \begin{tikzpicture}[x=1pt,y=1pt,font=\sffamily] …

Of course other options, or lists of options, can be specified as well.

@hbuschme hbuschme changed the title New argument to provide additional options to tikzpicture. New argument to provide additional options to tikzpicture Aug 25, 2016
@hbuschme hbuschme changed the title New argument to provide additional options to tikzpicture New argument to provide additional options to tikzpicture environment Aug 25, 2016
@yihui
Copy link
Collaborator

yihui commented Aug 30, 2016

Looks reasonable to me. Cc @krlmlr

Copy link
Collaborator

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request. Please let me know if you're still interested in this.

@@ -315,6 +317,7 @@ static Rboolean TikZ_Setup(
tikzInfo->onefile = onefile;
tikzInfo->timestamp = timestamp;
tikzInfo->verbose = verbose;
tikzInfo->pictureOptions = calloc_strcpy(pictureOptions);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to free this after we're done?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need a call to free() that corresponds to the calloc_strcpy() call.

@@ -172,6 +172,7 @@ SEXP TikZ_StartDevice ( SEXP args ){
int maxSymbolicColors = asInteger(CAR(args)); args = CDR(args);
Rboolean timestamp = asLogical(CAR(args)); args = CDR(args);
Rboolean verbose = asLogical(CAR(args)); args = CDR(args);
const char *pictureOptions = CHAR(asChar(CAR(args))); args = CDR(args);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly worried about protection here, because asChar() might allocate memory in corner cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe CHAR(PROTECT(asChar(...))), and then increase the number passed to UNPROTECT() by one?

@krlmlr krlmlr closed this Mar 10, 2018
@hbuschme
Copy link
Author

hbuschme commented Mar 14, 2018

Yes, I'm still interested in this, and I thought that I checked this PR now and then – apparently not, since I did not see your question from August 2017, sorry. I just got a notification about the closing of this PR and would be interested in re-opening it.

Concerning your questions, I'm not a C/C++ expert and am afraid that I cannot answer your memory-related questions competently.

Are you willing to continue?

@krlmlr
Copy link
Collaborator

krlmlr commented Mar 14, 2018

Sure, I can reopen it. I have just pushed an update to tikzDevice to CRAN, but it hasn't been accepted yet. After that I'll be looking for a new maintainer who will be more responsive hopefully ;-)

@krlmlr krlmlr reopened this Mar 14, 2018
@krlmlr
Copy link
Collaborator

krlmlr commented Mar 14, 2018

Could you please take a look at the conflict?

* Added an argument pictureOptions to the R function `tikz`.
* Added the argument to the C function `TikZ_Setup` and the
  structure tikzDevDesc.
* Made use of the argument, if provided, in the the C
  function `TikZ_StartDevice`.
* Added R documentation and rebuild documentation with roxygen.
* Added argument to vignette (in sec. 3.2 'Usage')
@hbuschme hbuschme force-pushed the tikzpicture-options branch from 326e72a to a6e8eed Compare March 15, 2018 15:16
@hbuschme
Copy link
Author

I've rebased my changes. It has no conflicts anymore and we can start tackling the questions you raised above. If you think that things should change, feel free to make these changes.

@rstub
Copy link
Member

rstub commented Sep 28, 2018

I am sorry that this has been lying around for so long. Can you please rebase the PR again? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants