Measure the remainder of a page if it has a title and inserting that into a dynamic command












0















Okay, so I'm currently writing a report (in the article class) which has a section full of chemical spectra. I figured that two spectra per page is a good number, so I write



RequirePackage{calc}
newlength{halfpage}
setlength{halfpage}{textheight/2}
newcommand{twoandabitperpage}{height=halfpage}
newcommandmygraphicspage[2]{centeringexpandafterincludegraphicsexpandafter[#1]{#2}}


This means that I can say mygraphicspage[twoandabitperpage]{spectrum_1.pdg} and mygraphicspage[twoandabitperpage]{spectrum_2.pdg}, and this will give me a nice couple of spectra on one page. (Note that I need the expandafters or else my code will break. I don't fully understand it, but it's there and I guess it works).



''Great!'' I thought to myself. In practice: not great. My spectra section is as follows:



part{Spectras!}
section{Spectrum One}
mygraphicspage[twoandabitperpage]{spectrum_1.pdf}
section{Spectrum Two}
mygraphicspage[twoandabitperpage]{spectrum_2.pdf}


Therefore, taking half of the page and making it my image height does not always work when there are sections and parts at play (for their titles make up more than is ideal of the page).



And so I went to Google: I found this



newlengthremainder
newcommandmeasurepage{dimexprpagegoal-pagetotal-baselineskiprelax}
remainder=measurepagerelaxtheremainder


So to my understanding (and I may be wrong, as I don't understand TeX very well [I couldn't figure out how to make the mygraphicspage command...]), what this does is it measures the rest of the page, probably through some black magic—after, of course, defining that the remaining length of the page shall be called the remainder. Then, it prints it? It that what that last line is for?



Anywho, I want to able to define



newlength{almosthalfpage}
setlength{almosthalfpage}{textheight-remainder/2}


Where remainder is defined by the page in question. This page will be specified when and only when I use the length almosthalfpage.



For example, say that my textheight=40em, and my part title makes up 4em, and I have two section titles making up 2 em each. Then, the remainder of my page is 32em. Therefore, my individual image heights should be 16em. This remainder of 32em is defined by remainder, but only when I specify the image height (which is a function of remainder) for that particular page.



I am really sorry if this makes no sense at all... Any help would be appreciated! And to a lesser degree of importance, I would appreciate anyone commenting on better ways to convey the code I currently have (i.e., should I be using def instead of newcommand, and let? How do I use those commands? etc. etc. ...).



Thank you!










share|improve this question























  • This seems a bit as if you're using a sledgehammer to crack a nut. Is it correct to say thaty basically you have a document with images and want to make sure that there are never more than two images on the same page?

    – sheß
    Apr 1 at 11:32











  • @sheß, not necessarily. I want to ensure that there are exactly two images per page, and I want them to fit nicely. I may very well be using a sledgehammer to crack a nut, as it were—; as I say, I am not very good with TeX at the minute. I have no doubt there are better ways to do this.

    – Christopher Tatlock
    Apr 1 at 11:44











  • Have you had a look at using subcaption or subfig? Alternatively you could use a rule to make your figures visually unchanged but let them take up the space of half a page? Lastly, if you're willing to give LaTeX a bit more freedom in deciding what to put where, you could follow this post: How can I adjust the number of figures latex will display on a page and also use usepackage{placeins} and FloatBarrier to make sure everything stays in the right sections

    – sheß
    Apr 1 at 11:51











  • Thank you @sheß, I will look into this :)

    – Christopher Tatlock
    Apr 7 at 11:47
















0















Okay, so I'm currently writing a report (in the article class) which has a section full of chemical spectra. I figured that two spectra per page is a good number, so I write



RequirePackage{calc}
newlength{halfpage}
setlength{halfpage}{textheight/2}
newcommand{twoandabitperpage}{height=halfpage}
newcommandmygraphicspage[2]{centeringexpandafterincludegraphicsexpandafter[#1]{#2}}


This means that I can say mygraphicspage[twoandabitperpage]{spectrum_1.pdg} and mygraphicspage[twoandabitperpage]{spectrum_2.pdg}, and this will give me a nice couple of spectra on one page. (Note that I need the expandafters or else my code will break. I don't fully understand it, but it's there and I guess it works).



''Great!'' I thought to myself. In practice: not great. My spectra section is as follows:



part{Spectras!}
section{Spectrum One}
mygraphicspage[twoandabitperpage]{spectrum_1.pdf}
section{Spectrum Two}
mygraphicspage[twoandabitperpage]{spectrum_2.pdf}


Therefore, taking half of the page and making it my image height does not always work when there are sections and parts at play (for their titles make up more than is ideal of the page).



And so I went to Google: I found this



newlengthremainder
newcommandmeasurepage{dimexprpagegoal-pagetotal-baselineskiprelax}
remainder=measurepagerelaxtheremainder


So to my understanding (and I may be wrong, as I don't understand TeX very well [I couldn't figure out how to make the mygraphicspage command...]), what this does is it measures the rest of the page, probably through some black magic—after, of course, defining that the remaining length of the page shall be called the remainder. Then, it prints it? It that what that last line is for?



Anywho, I want to able to define



newlength{almosthalfpage}
setlength{almosthalfpage}{textheight-remainder/2}


Where remainder is defined by the page in question. This page will be specified when and only when I use the length almosthalfpage.



For example, say that my textheight=40em, and my part title makes up 4em, and I have two section titles making up 2 em each. Then, the remainder of my page is 32em. Therefore, my individual image heights should be 16em. This remainder of 32em is defined by remainder, but only when I specify the image height (which is a function of remainder) for that particular page.



I am really sorry if this makes no sense at all... Any help would be appreciated! And to a lesser degree of importance, I would appreciate anyone commenting on better ways to convey the code I currently have (i.e., should I be using def instead of newcommand, and let? How do I use those commands? etc. etc. ...).



Thank you!










share|improve this question























  • This seems a bit as if you're using a sledgehammer to crack a nut. Is it correct to say thaty basically you have a document with images and want to make sure that there are never more than two images on the same page?

    – sheß
    Apr 1 at 11:32











  • @sheß, not necessarily. I want to ensure that there are exactly two images per page, and I want them to fit nicely. I may very well be using a sledgehammer to crack a nut, as it were—; as I say, I am not very good with TeX at the minute. I have no doubt there are better ways to do this.

    – Christopher Tatlock
    Apr 1 at 11:44











  • Have you had a look at using subcaption or subfig? Alternatively you could use a rule to make your figures visually unchanged but let them take up the space of half a page? Lastly, if you're willing to give LaTeX a bit more freedom in deciding what to put where, you could follow this post: How can I adjust the number of figures latex will display on a page and also use usepackage{placeins} and FloatBarrier to make sure everything stays in the right sections

    – sheß
    Apr 1 at 11:51











  • Thank you @sheß, I will look into this :)

    – Christopher Tatlock
    Apr 7 at 11:47














0












0








0


0






Okay, so I'm currently writing a report (in the article class) which has a section full of chemical spectra. I figured that two spectra per page is a good number, so I write



RequirePackage{calc}
newlength{halfpage}
setlength{halfpage}{textheight/2}
newcommand{twoandabitperpage}{height=halfpage}
newcommandmygraphicspage[2]{centeringexpandafterincludegraphicsexpandafter[#1]{#2}}


This means that I can say mygraphicspage[twoandabitperpage]{spectrum_1.pdg} and mygraphicspage[twoandabitperpage]{spectrum_2.pdg}, and this will give me a nice couple of spectra on one page. (Note that I need the expandafters or else my code will break. I don't fully understand it, but it's there and I guess it works).



''Great!'' I thought to myself. In practice: not great. My spectra section is as follows:



part{Spectras!}
section{Spectrum One}
mygraphicspage[twoandabitperpage]{spectrum_1.pdf}
section{Spectrum Two}
mygraphicspage[twoandabitperpage]{spectrum_2.pdf}


Therefore, taking half of the page and making it my image height does not always work when there are sections and parts at play (for their titles make up more than is ideal of the page).



And so I went to Google: I found this



newlengthremainder
newcommandmeasurepage{dimexprpagegoal-pagetotal-baselineskiprelax}
remainder=measurepagerelaxtheremainder


So to my understanding (and I may be wrong, as I don't understand TeX very well [I couldn't figure out how to make the mygraphicspage command...]), what this does is it measures the rest of the page, probably through some black magic—after, of course, defining that the remaining length of the page shall be called the remainder. Then, it prints it? It that what that last line is for?



Anywho, I want to able to define



newlength{almosthalfpage}
setlength{almosthalfpage}{textheight-remainder/2}


Where remainder is defined by the page in question. This page will be specified when and only when I use the length almosthalfpage.



For example, say that my textheight=40em, and my part title makes up 4em, and I have two section titles making up 2 em each. Then, the remainder of my page is 32em. Therefore, my individual image heights should be 16em. This remainder of 32em is defined by remainder, but only when I specify the image height (which is a function of remainder) for that particular page.



I am really sorry if this makes no sense at all... Any help would be appreciated! And to a lesser degree of importance, I would appreciate anyone commenting on better ways to convey the code I currently have (i.e., should I be using def instead of newcommand, and let? How do I use those commands? etc. etc. ...).



Thank you!










share|improve this question














Okay, so I'm currently writing a report (in the article class) which has a section full of chemical spectra. I figured that two spectra per page is a good number, so I write



RequirePackage{calc}
newlength{halfpage}
setlength{halfpage}{textheight/2}
newcommand{twoandabitperpage}{height=halfpage}
newcommandmygraphicspage[2]{centeringexpandafterincludegraphicsexpandafter[#1]{#2}}


This means that I can say mygraphicspage[twoandabitperpage]{spectrum_1.pdg} and mygraphicspage[twoandabitperpage]{spectrum_2.pdg}, and this will give me a nice couple of spectra on one page. (Note that I need the expandafters or else my code will break. I don't fully understand it, but it's there and I guess it works).



''Great!'' I thought to myself. In practice: not great. My spectra section is as follows:



part{Spectras!}
section{Spectrum One}
mygraphicspage[twoandabitperpage]{spectrum_1.pdf}
section{Spectrum Two}
mygraphicspage[twoandabitperpage]{spectrum_2.pdf}


Therefore, taking half of the page and making it my image height does not always work when there are sections and parts at play (for their titles make up more than is ideal of the page).



And so I went to Google: I found this



newlengthremainder
newcommandmeasurepage{dimexprpagegoal-pagetotal-baselineskiprelax}
remainder=measurepagerelaxtheremainder


So to my understanding (and I may be wrong, as I don't understand TeX very well [I couldn't figure out how to make the mygraphicspage command...]), what this does is it measures the rest of the page, probably through some black magic—after, of course, defining that the remaining length of the page shall be called the remainder. Then, it prints it? It that what that last line is for?



Anywho, I want to able to define



newlength{almosthalfpage}
setlength{almosthalfpage}{textheight-remainder/2}


Where remainder is defined by the page in question. This page will be specified when and only when I use the length almosthalfpage.



For example, say that my textheight=40em, and my part title makes up 4em, and I have two section titles making up 2 em each. Then, the remainder of my page is 32em. Therefore, my individual image heights should be 16em. This remainder of 32em is defined by remainder, but only when I specify the image height (which is a function of remainder) for that particular page.



I am really sorry if this makes no sense at all... Any help would be appreciated! And to a lesser degree of importance, I would appreciate anyone commenting on better ways to convey the code I currently have (i.e., should I be using def instead of newcommand, and let? How do I use those commands? etc. etc. ...).



Thank you!







macros lengths includegraphics page measure






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 1 at 10:48









Christopher TatlockChristopher Tatlock

161




161













  • This seems a bit as if you're using a sledgehammer to crack a nut. Is it correct to say thaty basically you have a document with images and want to make sure that there are never more than two images on the same page?

    – sheß
    Apr 1 at 11:32











  • @sheß, not necessarily. I want to ensure that there are exactly two images per page, and I want them to fit nicely. I may very well be using a sledgehammer to crack a nut, as it were—; as I say, I am not very good with TeX at the minute. I have no doubt there are better ways to do this.

    – Christopher Tatlock
    Apr 1 at 11:44











  • Have you had a look at using subcaption or subfig? Alternatively you could use a rule to make your figures visually unchanged but let them take up the space of half a page? Lastly, if you're willing to give LaTeX a bit more freedom in deciding what to put where, you could follow this post: How can I adjust the number of figures latex will display on a page and also use usepackage{placeins} and FloatBarrier to make sure everything stays in the right sections

    – sheß
    Apr 1 at 11:51











  • Thank you @sheß, I will look into this :)

    – Christopher Tatlock
    Apr 7 at 11:47



















  • This seems a bit as if you're using a sledgehammer to crack a nut. Is it correct to say thaty basically you have a document with images and want to make sure that there are never more than two images on the same page?

    – sheß
    Apr 1 at 11:32











  • @sheß, not necessarily. I want to ensure that there are exactly two images per page, and I want them to fit nicely. I may very well be using a sledgehammer to crack a nut, as it were—; as I say, I am not very good with TeX at the minute. I have no doubt there are better ways to do this.

    – Christopher Tatlock
    Apr 1 at 11:44











  • Have you had a look at using subcaption or subfig? Alternatively you could use a rule to make your figures visually unchanged but let them take up the space of half a page? Lastly, if you're willing to give LaTeX a bit more freedom in deciding what to put where, you could follow this post: How can I adjust the number of figures latex will display on a page and also use usepackage{placeins} and FloatBarrier to make sure everything stays in the right sections

    – sheß
    Apr 1 at 11:51











  • Thank you @sheß, I will look into this :)

    – Christopher Tatlock
    Apr 7 at 11:47

















This seems a bit as if you're using a sledgehammer to crack a nut. Is it correct to say thaty basically you have a document with images and want to make sure that there are never more than two images on the same page?

– sheß
Apr 1 at 11:32





This seems a bit as if you're using a sledgehammer to crack a nut. Is it correct to say thaty basically you have a document with images and want to make sure that there are never more than two images on the same page?

– sheß
Apr 1 at 11:32













@sheß, not necessarily. I want to ensure that there are exactly two images per page, and I want them to fit nicely. I may very well be using a sledgehammer to crack a nut, as it were—; as I say, I am not very good with TeX at the minute. I have no doubt there are better ways to do this.

– Christopher Tatlock
Apr 1 at 11:44





@sheß, not necessarily. I want to ensure that there are exactly two images per page, and I want them to fit nicely. I may very well be using a sledgehammer to crack a nut, as it were—; as I say, I am not very good with TeX at the minute. I have no doubt there are better ways to do this.

– Christopher Tatlock
Apr 1 at 11:44













Have you had a look at using subcaption or subfig? Alternatively you could use a rule to make your figures visually unchanged but let them take up the space of half a page? Lastly, if you're willing to give LaTeX a bit more freedom in deciding what to put where, you could follow this post: How can I adjust the number of figures latex will display on a page and also use usepackage{placeins} and FloatBarrier to make sure everything stays in the right sections

– sheß
Apr 1 at 11:51





Have you had a look at using subcaption or subfig? Alternatively you could use a rule to make your figures visually unchanged but let them take up the space of half a page? Lastly, if you're willing to give LaTeX a bit more freedom in deciding what to put where, you could follow this post: How can I adjust the number of figures latex will display on a page and also use usepackage{placeins} and FloatBarrier to make sure everything stays in the right sections

– sheß
Apr 1 at 11:51













Thank you @sheß, I will look into this :)

– Christopher Tatlock
Apr 7 at 11:47





Thank you @sheß, I will look into this :)

– Christopher Tatlock
Apr 7 at 11:47










0






active

oldest

votes












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%2f482559%2fmeasure-the-remainder-of-a-page-if-it-has-a-title-and-inserting-that-into-a-dyna%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f482559%2fmeasure-the-remainder-of-a-page-if-it-has-a-title-and-inserting-that-into-a-dyna%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

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?