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

Allow settings axis width and height from an external latex document #261

Open
KristofferC opened this issue Apr 15, 2021 · 3 comments
Open

Comments

@KristofferC
Copy link
Owner

KristofferC commented Apr 15, 2021

A common workflow with PGFPlotsX.jl is that you export a figure .tex file (without a preamble) and then include it in a main .tex document. Often, you want to be able to set the width and height of this figure from the main .tex document. What you can do is to include the figure with \includegraphics and then use e.g. the width option to set the width of the figure. This however leads to the drawback that the text of the figure is scaled as well, meaning it looks inconsistent with the rest of the document.

The way to properly resize a figure (without scaling the text) is to set the width and height options of the axis. This is however something you do from within the exported .tex file which is a bit awkward.

What other software does, for example matlab2tikz (https://tomlankhorst.nl/matlab-to-latex-with-matlab2tikz/) is that they allow you to set the height and width like this:

\begin{figure}[!htb]
\centering
    \setlength\fheight{0.35\textwidth} 
    \setlength\fwidth{0.85\textwidth}
    \input{res_cb_stress.tex}
\end{figure}

The fheight and fwidth are set from the main tex file and there is no need to modify the exported figure .tex file if one wants to change its size. This does not scale the figure text.

Having some option of exporting a figure to support this workflow probably makes sense.

@KristofferC KristofferC changed the title Allow settings axis width and height from an eter Allow settings axis width and height from an external latex document Apr 15, 2021
@KristofferC
Copy link
Owner Author

Alternatively, it is already possible to do this from PGFPlotsX:

image

So maybe we should just add some docs on how to do this.

@tpapp
Copy link
Collaborator

tpapp commented Apr 15, 2021

I think that just documenting the preamble solution would be best, as it makes the variables explicit.

@KristofferC
Copy link
Owner Author

Agree

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

No branches or pull requests

2 participants