gillescastel / inkscape-figures

Inkscape figure manager
MIT License
557 stars 119 forks source link

Export .pdf_tex containing whole inkscape's page instead of just drawn object #6

Closed mariobiondi1 closed 5 years ago

mariobiondi1 commented 5 years ago

Hi, sorry for the stupid issue. Maybe it's just my problem.

Is there perhaps a way to have only my drawn object as an included .pdf_tex file instead of the whole page?

Screenshots attached to explain my problem.

Maybe it's just my lacking knowledge of Inkscape the issue.

Thank you again for this wonderful script.

gillescastel commented 5 years ago

Thanks for this issue! No need to be sorry.

This behaviour is currently hard coded here: (--export-area-page)

https://github.com/gillescastel/inkscape-figures/blob/2ec92c5252030f5fee669e99a3358ca6ca48f6e7/inkscapefigures/main.py#L153-L159

I suppose I could make --export-area-drawing an option of inkscape-figures, but I don't know if that would be useful, for the following reason: The code for including figures makes them as wide as the page is. Suppose your drawing looks like this: image

Only exporting the drawing and not the full page would result in the following:

image

Exporting the page would result in this: image

I'd suppose you could also export the drawing and change the width of the included figure in your LaTeX document, but fiddling with numbers to get the desired width is quite annoying after a while – especially if you can do it more easily (with instant visual feedback) in Inkscape.

The shortcut in Inkscape to change the page size is Ctrl-Shift-R (which resizes the page to your selection, and if nothing is selected to your drawing). A trick I find useful is drawing a rectangle (shortcut R), then pressing Ctrl-Shift-R to resize the page to that rectangle, then pressing Delete to delete it. This resizes the page to the selected rectangle.

What do you think? Does this answer your question?

mariobiondi1 commented 5 years ago

Hi Gilles, thank you for the extensive reply.

I see why you coded the --export-area-page and I agree that, in general, it looks better.

My issue with it was that my notebook monitor isn't that large and, fairly often, I only have a border of the inkscape canvas available to draw on.

After I posted the issue I looked around and found exactly that Ctrl-Shift-R after A shortcut you talked about. I simply remapped Ctrl-Shift-R to Alt-B. For reasons this is way more comfortable for me.

I then included in the inkscape-figures latex export a \incfig{x}{name} by default set on x=0.5. This number goes in the LaTeX preamble to scale the drawing \def\svgwidth{x\columwidth}.

It all works fantastically now.

I could theoretically recode to --export-area-drawing, but I prefer to have the resize canvas as an option.

Thank you again :)