Automatic width setting in LyX












8















Is there any preference setting so that LyX automatically adjusts images width to linewidth when they are added, instead of doing so by hand whenever a new image is inserted?
Setting I want to be adjusted automatically, adjusted manually in this cap.










share|improve this question

























  • Yes, exactly what I wanted, thank you very much @Werner!

    – nonKreon
    Jan 5 '14 at 17:19













  • Also consider using graphics groups. See Help > User Guide, Section 4.4.2 Grouping of Image Settings

    – scottkosty
    Oct 27 '14 at 1:18
















8















Is there any preference setting so that LyX automatically adjusts images width to linewidth when they are added, instead of doing so by hand whenever a new image is inserted?
Setting I want to be adjusted automatically, adjusted manually in this cap.










share|improve this question

























  • Yes, exactly what I wanted, thank you very much @Werner!

    – nonKreon
    Jan 5 '14 at 17:19













  • Also consider using graphics groups. See Help > User Guide, Section 4.4.2 Grouping of Image Settings

    – scottkosty
    Oct 27 '14 at 1:18














8












8








8


5






Is there any preference setting so that LyX automatically adjusts images width to linewidth when they are added, instead of doing so by hand whenever a new image is inserted?
Setting I want to be adjusted automatically, adjusted manually in this cap.










share|improve this question
















Is there any preference setting so that LyX automatically adjusts images width to linewidth when they are added, instead of doing so by hand whenever a new image is inserted?
Setting I want to be adjusted automatically, adjusted manually in this cap.







graphics lyx dimensions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 26 '14 at 17:12









yo'

39.5k8124232




39.5k8124232










asked Jan 5 '14 at 15:39









nonKreonnonKreon

4314




4314













  • Yes, exactly what I wanted, thank you very much @Werner!

    – nonKreon
    Jan 5 '14 at 17:19













  • Also consider using graphics groups. See Help > User Guide, Section 4.4.2 Grouping of Image Settings

    – scottkosty
    Oct 27 '14 at 1:18



















  • Yes, exactly what I wanted, thank you very much @Werner!

    – nonKreon
    Jan 5 '14 at 17:19













  • Also consider using graphics groups. See Help > User Guide, Section 4.4.2 Grouping of Image Settings

    – scottkosty
    Oct 27 '14 at 1:18

















Yes, exactly what I wanted, thank you very much @Werner!

– nonKreon
Jan 5 '14 at 17:19







Yes, exactly what I wanted, thank you very much @Werner!

– nonKreon
Jan 5 '14 at 17:19















Also consider using graphics groups. See Help > User Guide, Section 4.4.2 Grouping of Image Settings

– scottkosty
Oct 27 '14 at 1:18





Also consider using graphics groups. See Help > User Guide, Section 4.4.2 Grouping of Image Settings

– scottkosty
Oct 27 '14 at 1:18










1 Answer
1






active

oldest

votes


















8














You can set the keys associated with includegraphics globally in your LaTeX Preamble by adding to it



setkeys{Gin}{width=linewidth}


This will resize all images (either enlarging or shrinking) to make them fit to linewidth. If you only wish to shrink image that are too large, you can use (from Resize images to half of text width only if too big for page margin):



makeatletter
setkeys{Gin}{width=ifdimGin@nat@width>linewidth
linewidth
else
Gin@nat@width
fi}
makeatother


Here Gin@nat@width is the natural width of the image to be included.






share|improve this answer


























  • This works perfectly if there are figure floats, otherwise causes latex to crash. How can I put this in an if statement such that if there is at least a figure float setkeys{Gin}{width=linewidth} else do nothing fi

    – nonKreon
    Jun 13 '17 at 20:30













  • @BerkerPeköz: That should not be the case. No figure floats typically mean no includegraphics and therefore no use of the Gin family of keys. One can test for the number of figures, say, in a document, but that should not be necessary here. Perhaps you can show your code to identify where you may be going wrong...?

    – Werner
    Jun 13 '17 at 20:40











  • thanks for your quick response after all these years :) A simple MWE would be documentclass{IEEEtran} setkeys{Gin}{width=linewidth} begin{document} This is a MWE end{document} If a figure float is present, the command runs beautifully but if not, it causes pdflatex to crash. I've been commenting it out when there is no figure and enable it as I add one, but I'm trying to automate this process with an if statement.

    – nonKreon
    Jun 14 '17 at 15:37






  • 1





    @BerkerPeköz: Ahhh. LyX inserts the use of the graphicx package if there are images included in the document, but otherwise removes it. Just add usepackage{graphicx} to your Document > Settings... > LaTeX Preamble before the makeatletter...makeatother addition I specify in the answer.

    – Werner
    Jun 14 '17 at 16:28











  • now it's robust to not having figures, and the solution is simple and beautiful it doesn't even need if statements. thank you so much :)

    – nonKreon
    Jun 15 '17 at 15:27













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f152545%2fautomatic-width-setting-in-lyx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









8














You can set the keys associated with includegraphics globally in your LaTeX Preamble by adding to it



setkeys{Gin}{width=linewidth}


This will resize all images (either enlarging or shrinking) to make them fit to linewidth. If you only wish to shrink image that are too large, you can use (from Resize images to half of text width only if too big for page margin):



makeatletter
setkeys{Gin}{width=ifdimGin@nat@width>linewidth
linewidth
else
Gin@nat@width
fi}
makeatother


Here Gin@nat@width is the natural width of the image to be included.






share|improve this answer


























  • This works perfectly if there are figure floats, otherwise causes latex to crash. How can I put this in an if statement such that if there is at least a figure float setkeys{Gin}{width=linewidth} else do nothing fi

    – nonKreon
    Jun 13 '17 at 20:30













  • @BerkerPeköz: That should not be the case. No figure floats typically mean no includegraphics and therefore no use of the Gin family of keys. One can test for the number of figures, say, in a document, but that should not be necessary here. Perhaps you can show your code to identify where you may be going wrong...?

    – Werner
    Jun 13 '17 at 20:40











  • thanks for your quick response after all these years :) A simple MWE would be documentclass{IEEEtran} setkeys{Gin}{width=linewidth} begin{document} This is a MWE end{document} If a figure float is present, the command runs beautifully but if not, it causes pdflatex to crash. I've been commenting it out when there is no figure and enable it as I add one, but I'm trying to automate this process with an if statement.

    – nonKreon
    Jun 14 '17 at 15:37






  • 1





    @BerkerPeköz: Ahhh. LyX inserts the use of the graphicx package if there are images included in the document, but otherwise removes it. Just add usepackage{graphicx} to your Document > Settings... > LaTeX Preamble before the makeatletter...makeatother addition I specify in the answer.

    – Werner
    Jun 14 '17 at 16:28











  • now it's robust to not having figures, and the solution is simple and beautiful it doesn't even need if statements. thank you so much :)

    – nonKreon
    Jun 15 '17 at 15:27


















8














You can set the keys associated with includegraphics globally in your LaTeX Preamble by adding to it



setkeys{Gin}{width=linewidth}


This will resize all images (either enlarging or shrinking) to make them fit to linewidth. If you only wish to shrink image that are too large, you can use (from Resize images to half of text width only if too big for page margin):



makeatletter
setkeys{Gin}{width=ifdimGin@nat@width>linewidth
linewidth
else
Gin@nat@width
fi}
makeatother


Here Gin@nat@width is the natural width of the image to be included.






share|improve this answer


























  • This works perfectly if there are figure floats, otherwise causes latex to crash. How can I put this in an if statement such that if there is at least a figure float setkeys{Gin}{width=linewidth} else do nothing fi

    – nonKreon
    Jun 13 '17 at 20:30













  • @BerkerPeköz: That should not be the case. No figure floats typically mean no includegraphics and therefore no use of the Gin family of keys. One can test for the number of figures, say, in a document, but that should not be necessary here. Perhaps you can show your code to identify where you may be going wrong...?

    – Werner
    Jun 13 '17 at 20:40











  • thanks for your quick response after all these years :) A simple MWE would be documentclass{IEEEtran} setkeys{Gin}{width=linewidth} begin{document} This is a MWE end{document} If a figure float is present, the command runs beautifully but if not, it causes pdflatex to crash. I've been commenting it out when there is no figure and enable it as I add one, but I'm trying to automate this process with an if statement.

    – nonKreon
    Jun 14 '17 at 15:37






  • 1





    @BerkerPeköz: Ahhh. LyX inserts the use of the graphicx package if there are images included in the document, but otherwise removes it. Just add usepackage{graphicx} to your Document > Settings... > LaTeX Preamble before the makeatletter...makeatother addition I specify in the answer.

    – Werner
    Jun 14 '17 at 16:28











  • now it's robust to not having figures, and the solution is simple and beautiful it doesn't even need if statements. thank you so much :)

    – nonKreon
    Jun 15 '17 at 15:27
















8












8








8







You can set the keys associated with includegraphics globally in your LaTeX Preamble by adding to it



setkeys{Gin}{width=linewidth}


This will resize all images (either enlarging or shrinking) to make them fit to linewidth. If you only wish to shrink image that are too large, you can use (from Resize images to half of text width only if too big for page margin):



makeatletter
setkeys{Gin}{width=ifdimGin@nat@width>linewidth
linewidth
else
Gin@nat@width
fi}
makeatother


Here Gin@nat@width is the natural width of the image to be included.






share|improve this answer















You can set the keys associated with includegraphics globally in your LaTeX Preamble by adding to it



setkeys{Gin}{width=linewidth}


This will resize all images (either enlarging or shrinking) to make them fit to linewidth. If you only wish to shrink image that are too large, you can use (from Resize images to half of text width only if too big for page margin):



makeatletter
setkeys{Gin}{width=ifdimGin@nat@width>linewidth
linewidth
else
Gin@nat@width
fi}
makeatother


Here Gin@nat@width is the natural width of the image to be included.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 15 at 16:38

























answered Jan 5 '14 at 19:09









WernerWerner

445k699801685




445k699801685













  • This works perfectly if there are figure floats, otherwise causes latex to crash. How can I put this in an if statement such that if there is at least a figure float setkeys{Gin}{width=linewidth} else do nothing fi

    – nonKreon
    Jun 13 '17 at 20:30













  • @BerkerPeköz: That should not be the case. No figure floats typically mean no includegraphics and therefore no use of the Gin family of keys. One can test for the number of figures, say, in a document, but that should not be necessary here. Perhaps you can show your code to identify where you may be going wrong...?

    – Werner
    Jun 13 '17 at 20:40











  • thanks for your quick response after all these years :) A simple MWE would be documentclass{IEEEtran} setkeys{Gin}{width=linewidth} begin{document} This is a MWE end{document} If a figure float is present, the command runs beautifully but if not, it causes pdflatex to crash. I've been commenting it out when there is no figure and enable it as I add one, but I'm trying to automate this process with an if statement.

    – nonKreon
    Jun 14 '17 at 15:37






  • 1





    @BerkerPeköz: Ahhh. LyX inserts the use of the graphicx package if there are images included in the document, but otherwise removes it. Just add usepackage{graphicx} to your Document > Settings... > LaTeX Preamble before the makeatletter...makeatother addition I specify in the answer.

    – Werner
    Jun 14 '17 at 16:28











  • now it's robust to not having figures, and the solution is simple and beautiful it doesn't even need if statements. thank you so much :)

    – nonKreon
    Jun 15 '17 at 15:27





















  • This works perfectly if there are figure floats, otherwise causes latex to crash. How can I put this in an if statement such that if there is at least a figure float setkeys{Gin}{width=linewidth} else do nothing fi

    – nonKreon
    Jun 13 '17 at 20:30













  • @BerkerPeköz: That should not be the case. No figure floats typically mean no includegraphics and therefore no use of the Gin family of keys. One can test for the number of figures, say, in a document, but that should not be necessary here. Perhaps you can show your code to identify where you may be going wrong...?

    – Werner
    Jun 13 '17 at 20:40











  • thanks for your quick response after all these years :) A simple MWE would be documentclass{IEEEtran} setkeys{Gin}{width=linewidth} begin{document} This is a MWE end{document} If a figure float is present, the command runs beautifully but if not, it causes pdflatex to crash. I've been commenting it out when there is no figure and enable it as I add one, but I'm trying to automate this process with an if statement.

    – nonKreon
    Jun 14 '17 at 15:37






  • 1





    @BerkerPeköz: Ahhh. LyX inserts the use of the graphicx package if there are images included in the document, but otherwise removes it. Just add usepackage{graphicx} to your Document > Settings... > LaTeX Preamble before the makeatletter...makeatother addition I specify in the answer.

    – Werner
    Jun 14 '17 at 16:28











  • now it's robust to not having figures, and the solution is simple and beautiful it doesn't even need if statements. thank you so much :)

    – nonKreon
    Jun 15 '17 at 15:27



















This works perfectly if there are figure floats, otherwise causes latex to crash. How can I put this in an if statement such that if there is at least a figure float setkeys{Gin}{width=linewidth} else do nothing fi

– nonKreon
Jun 13 '17 at 20:30







This works perfectly if there are figure floats, otherwise causes latex to crash. How can I put this in an if statement such that if there is at least a figure float setkeys{Gin}{width=linewidth} else do nothing fi

– nonKreon
Jun 13 '17 at 20:30















@BerkerPeköz: That should not be the case. No figure floats typically mean no includegraphics and therefore no use of the Gin family of keys. One can test for the number of figures, say, in a document, but that should not be necessary here. Perhaps you can show your code to identify where you may be going wrong...?

– Werner
Jun 13 '17 at 20:40





@BerkerPeköz: That should not be the case. No figure floats typically mean no includegraphics and therefore no use of the Gin family of keys. One can test for the number of figures, say, in a document, but that should not be necessary here. Perhaps you can show your code to identify where you may be going wrong...?

– Werner
Jun 13 '17 at 20:40













thanks for your quick response after all these years :) A simple MWE would be documentclass{IEEEtran} setkeys{Gin}{width=linewidth} begin{document} This is a MWE end{document} If a figure float is present, the command runs beautifully but if not, it causes pdflatex to crash. I've been commenting it out when there is no figure and enable it as I add one, but I'm trying to automate this process with an if statement.

– nonKreon
Jun 14 '17 at 15:37





thanks for your quick response after all these years :) A simple MWE would be documentclass{IEEEtran} setkeys{Gin}{width=linewidth} begin{document} This is a MWE end{document} If a figure float is present, the command runs beautifully but if not, it causes pdflatex to crash. I've been commenting it out when there is no figure and enable it as I add one, but I'm trying to automate this process with an if statement.

– nonKreon
Jun 14 '17 at 15:37




1




1





@BerkerPeköz: Ahhh. LyX inserts the use of the graphicx package if there are images included in the document, but otherwise removes it. Just add usepackage{graphicx} to your Document > Settings... > LaTeX Preamble before the makeatletter...makeatother addition I specify in the answer.

– Werner
Jun 14 '17 at 16:28





@BerkerPeköz: Ahhh. LyX inserts the use of the graphicx package if there are images included in the document, but otherwise removes it. Just add usepackage{graphicx} to your Document > Settings... > LaTeX Preamble before the makeatletter...makeatother addition I specify in the answer.

– Werner
Jun 14 '17 at 16:28













now it's robust to not having figures, and the solution is simple and beautiful it doesn't even need if statements. thank you so much :)

– nonKreon
Jun 15 '17 at 15:27







now it's robust to not having figures, and the solution is simple and beautiful it doesn't even need if statements. thank you so much :)

– nonKreon
Jun 15 '17 at 15:27




















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f152545%2fautomatic-width-setting-in-lyx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?