How to have a figure touch the top edge of the page?












1















I want to have a letterhead format with the corporate logo at the very top of the paper. I have figured out how the fill the graphics with the full breadth of the page with the information on this webpage-
How to have a figure touch the edge of the page?.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}

begin{document}

%
newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}
%

begin{flushleft}
mbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{includegraphics[width=paperwidth]{logo}}%
}
end{flushleft}

section{A test section}
lipsum[4]

end{document}


I got the result like this -
enter image description here



However I'm still struggling to align the top side of the graphics (logo) with the top edge of the paper.



Appreciate any help!










share|improve this question























  • Welcome to TeX.SE! Do you mean to put the logo into the header with package fancyhdr? Should it be on every page of the document or only the first page?

    – Kurt
    Jan 9 at 7:30













  • I have not found anything anywhere putting the graphics right to the very top of the page. I want this for the first page for now. But might also want every page afterwards. It does not matter whether it's implemented with the header or in the 'body' of the article. (Of course it's more elegant with header if it's a letter header). Thanks. I can think of an ugly workaround by making a blank pdg page with header with word and then include in TeX. But that's really ugly workaround and hope to see more elegant ways.

    – Max
    Jan 9 at 7:36


















1















I want to have a letterhead format with the corporate logo at the very top of the paper. I have figured out how the fill the graphics with the full breadth of the page with the information on this webpage-
How to have a figure touch the edge of the page?.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}

begin{document}

%
newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}
%

begin{flushleft}
mbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{includegraphics[width=paperwidth]{logo}}%
}
end{flushleft}

section{A test section}
lipsum[4]

end{document}


I got the result like this -
enter image description here



However I'm still struggling to align the top side of the graphics (logo) with the top edge of the paper.



Appreciate any help!










share|improve this question























  • Welcome to TeX.SE! Do you mean to put the logo into the header with package fancyhdr? Should it be on every page of the document or only the first page?

    – Kurt
    Jan 9 at 7:30













  • I have not found anything anywhere putting the graphics right to the very top of the page. I want this for the first page for now. But might also want every page afterwards. It does not matter whether it's implemented with the header or in the 'body' of the article. (Of course it's more elegant with header if it's a letter header). Thanks. I can think of an ugly workaround by making a blank pdg page with header with word and then include in TeX. But that's really ugly workaround and hope to see more elegant ways.

    – Max
    Jan 9 at 7:36
















1












1








1








I want to have a letterhead format with the corporate logo at the very top of the paper. I have figured out how the fill the graphics with the full breadth of the page with the information on this webpage-
How to have a figure touch the edge of the page?.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}

begin{document}

%
newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}
%

begin{flushleft}
mbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{includegraphics[width=paperwidth]{logo}}%
}
end{flushleft}

section{A test section}
lipsum[4]

end{document}


I got the result like this -
enter image description here



However I'm still struggling to align the top side of the graphics (logo) with the top edge of the paper.



Appreciate any help!










share|improve this question














I want to have a letterhead format with the corporate logo at the very top of the paper. I have figured out how the fill the graphics with the full breadth of the page with the information on this webpage-
How to have a figure touch the edge of the page?.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}

begin{document}

%
newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}
%

begin{flushleft}
mbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{includegraphics[width=paperwidth]{logo}}%
}
end{flushleft}

section{A test section}
lipsum[4]

end{document}


I got the result like this -
enter image description here



However I'm still struggling to align the top side of the graphics (logo) with the top edge of the paper.



Appreciate any help!







graphics positioning alignment






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 9 at 7:16









MaxMax

305




305













  • Welcome to TeX.SE! Do you mean to put the logo into the header with package fancyhdr? Should it be on every page of the document or only the first page?

    – Kurt
    Jan 9 at 7:30













  • I have not found anything anywhere putting the graphics right to the very top of the page. I want this for the first page for now. But might also want every page afterwards. It does not matter whether it's implemented with the header or in the 'body' of the article. (Of course it's more elegant with header if it's a letter header). Thanks. I can think of an ugly workaround by making a blank pdg page with header with word and then include in TeX. But that's really ugly workaround and hope to see more elegant ways.

    – Max
    Jan 9 at 7:36





















  • Welcome to TeX.SE! Do you mean to put the logo into the header with package fancyhdr? Should it be on every page of the document or only the first page?

    – Kurt
    Jan 9 at 7:30













  • I have not found anything anywhere putting the graphics right to the very top of the page. I want this for the first page for now. But might also want every page afterwards. It does not matter whether it's implemented with the header or in the 'body' of the article. (Of course it's more elegant with header if it's a letter header). Thanks. I can think of an ugly workaround by making a blank pdg page with header with word and then include in TeX. But that's really ugly workaround and hope to see more elegant ways.

    – Max
    Jan 9 at 7:36



















Welcome to TeX.SE! Do you mean to put the logo into the header with package fancyhdr? Should it be on every page of the document or only the first page?

– Kurt
Jan 9 at 7:30







Welcome to TeX.SE! Do you mean to put the logo into the header with package fancyhdr? Should it be on every page of the document or only the first page?

– Kurt
Jan 9 at 7:30















I have not found anything anywhere putting the graphics right to the very top of the page. I want this for the first page for now. But might also want every page afterwards. It does not matter whether it's implemented with the header or in the 'body' of the article. (Of course it's more elegant with header if it's a letter header). Thanks. I can think of an ugly workaround by making a blank pdg page with header with word and then include in TeX. But that's really ugly workaround and hope to see more elegant ways.

– Max
Jan 9 at 7:36







I have not found anything anywhere putting the graphics right to the very top of the page. I want this for the first page for now. But might also want every page afterwards. It does not matter whether it's implemented with the header or in the 'body' of the article. (Of course it's more elegant with header if it's a letter header). Thanks. I can think of an ugly workaround by making a blank pdg page with header with word and then include in TeX. But that's really ugly workaround and hope to see more elegant ways.

– Max
Jan 9 at 7:36












1 Answer
1






active

oldest

votes


















0














You need to raise the image into the upper margin. This can be done using raisebox. I used the layout package with the layout macro to display all length used by LaTeX to create the top of the page. The distance is 1in+voffset+topmargin+headheight+headsep. You need to use the optional argument to set the new height by subtracting that value from the original height, which is defined as height here. This also works if put into a header by simply removing headheight and headsep from the equation.



Of course you can also my adjustbox package to do all this with less code.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}
usepackage{adjustbox}


newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}

newcommand{dimtotop}{%
dimexprheight-1in-voffset-topmargin-headheight-headseprelax}


begin{document}

clearpage
begin{flushleft}
hbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{raisebox{0pt}[dimtotop]{includegraphics[width=paperwidth]{example-image}}}%
}
end{flushleft}

section{A test section}
lipsum[4]

clearpage
noindentadjustimage{width=paperwidth,
lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5width-csname @totalleftmarginendcsname}, % adjustbox version v1.2 2019/01/04 provides this as 'pagecenter' key
set height=height-1in-voffset-topmargin-headheight-headsep}{example-image}

section{A test section}
lipsum[4]


end{document}


enter image description here






share|improve this answer
























  • Thanks Martin. That's exactly what I wanted. Seems like I had not fully understood the command raisebox. I was also not aware of the height command - I had overlooked the height command (and width, depth, as well) in the book 'The not so short introduction to LaTeX2e'.

    – Max
    Jan 9 at 8:15













  • @Max: height, width and depth are defined internally by raisebox when processing the length values. Also the adjustbox package does the same.

    – Martin Scharrer
    Jan 9 at 8:17











  • Oh you showed 2 ways of doing it. That's awesome. Thanks!

    – Max
    Jan 9 at 8:23











  • @Max: The adjustbox update from last week makes the horizontal adjustment easier, just replace the lap=... stuff with a simple pagecenter. I didn't used it yet, as not everyone might have the update yet.

    – Martin Scharrer
    Jan 9 at 8:27











  • Having learned from Martin's code, I also changed the dimtorightedge definition by replacing oddsidemargin withifoddpageoddsidemarginelseevensidemarginfi to add more flexibility. But I don't see any problem with the simpler definition without changing the default page layout.

    – Max
    Jan 9 at 8:39











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%2f469300%2fhow-to-have-a-figure-touch-the-top-edge-of-the-page%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









0














You need to raise the image into the upper margin. This can be done using raisebox. I used the layout package with the layout macro to display all length used by LaTeX to create the top of the page. The distance is 1in+voffset+topmargin+headheight+headsep. You need to use the optional argument to set the new height by subtracting that value from the original height, which is defined as height here. This also works if put into a header by simply removing headheight and headsep from the equation.



Of course you can also my adjustbox package to do all this with less code.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}
usepackage{adjustbox}


newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}

newcommand{dimtotop}{%
dimexprheight-1in-voffset-topmargin-headheight-headseprelax}


begin{document}

clearpage
begin{flushleft}
hbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{raisebox{0pt}[dimtotop]{includegraphics[width=paperwidth]{example-image}}}%
}
end{flushleft}

section{A test section}
lipsum[4]

clearpage
noindentadjustimage{width=paperwidth,
lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5width-csname @totalleftmarginendcsname}, % adjustbox version v1.2 2019/01/04 provides this as 'pagecenter' key
set height=height-1in-voffset-topmargin-headheight-headsep}{example-image}

section{A test section}
lipsum[4]


end{document}


enter image description here






share|improve this answer
























  • Thanks Martin. That's exactly what I wanted. Seems like I had not fully understood the command raisebox. I was also not aware of the height command - I had overlooked the height command (and width, depth, as well) in the book 'The not so short introduction to LaTeX2e'.

    – Max
    Jan 9 at 8:15













  • @Max: height, width and depth are defined internally by raisebox when processing the length values. Also the adjustbox package does the same.

    – Martin Scharrer
    Jan 9 at 8:17











  • Oh you showed 2 ways of doing it. That's awesome. Thanks!

    – Max
    Jan 9 at 8:23











  • @Max: The adjustbox update from last week makes the horizontal adjustment easier, just replace the lap=... stuff with a simple pagecenter. I didn't used it yet, as not everyone might have the update yet.

    – Martin Scharrer
    Jan 9 at 8:27











  • Having learned from Martin's code, I also changed the dimtorightedge definition by replacing oddsidemargin withifoddpageoddsidemarginelseevensidemarginfi to add more flexibility. But I don't see any problem with the simpler definition without changing the default page layout.

    – Max
    Jan 9 at 8:39
















0














You need to raise the image into the upper margin. This can be done using raisebox. I used the layout package with the layout macro to display all length used by LaTeX to create the top of the page. The distance is 1in+voffset+topmargin+headheight+headsep. You need to use the optional argument to set the new height by subtracting that value from the original height, which is defined as height here. This also works if put into a header by simply removing headheight and headsep from the equation.



Of course you can also my adjustbox package to do all this with less code.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}
usepackage{adjustbox}


newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}

newcommand{dimtotop}{%
dimexprheight-1in-voffset-topmargin-headheight-headseprelax}


begin{document}

clearpage
begin{flushleft}
hbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{raisebox{0pt}[dimtotop]{includegraphics[width=paperwidth]{example-image}}}%
}
end{flushleft}

section{A test section}
lipsum[4]

clearpage
noindentadjustimage{width=paperwidth,
lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5width-csname @totalleftmarginendcsname}, % adjustbox version v1.2 2019/01/04 provides this as 'pagecenter' key
set height=height-1in-voffset-topmargin-headheight-headsep}{example-image}

section{A test section}
lipsum[4]


end{document}


enter image description here






share|improve this answer
























  • Thanks Martin. That's exactly what I wanted. Seems like I had not fully understood the command raisebox. I was also not aware of the height command - I had overlooked the height command (and width, depth, as well) in the book 'The not so short introduction to LaTeX2e'.

    – Max
    Jan 9 at 8:15













  • @Max: height, width and depth are defined internally by raisebox when processing the length values. Also the adjustbox package does the same.

    – Martin Scharrer
    Jan 9 at 8:17











  • Oh you showed 2 ways of doing it. That's awesome. Thanks!

    – Max
    Jan 9 at 8:23











  • @Max: The adjustbox update from last week makes the horizontal adjustment easier, just replace the lap=... stuff with a simple pagecenter. I didn't used it yet, as not everyone might have the update yet.

    – Martin Scharrer
    Jan 9 at 8:27











  • Having learned from Martin's code, I also changed the dimtorightedge definition by replacing oddsidemargin withifoddpageoddsidemarginelseevensidemarginfi to add more flexibility. But I don't see any problem with the simpler definition without changing the default page layout.

    – Max
    Jan 9 at 8:39














0












0








0







You need to raise the image into the upper margin. This can be done using raisebox. I used the layout package with the layout macro to display all length used by LaTeX to create the top of the page. The distance is 1in+voffset+topmargin+headheight+headsep. You need to use the optional argument to set the new height by subtracting that value from the original height, which is defined as height here. This also works if put into a header by simply removing headheight and headsep from the equation.



Of course you can also my adjustbox package to do all this with less code.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}
usepackage{adjustbox}


newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}

newcommand{dimtotop}{%
dimexprheight-1in-voffset-topmargin-headheight-headseprelax}


begin{document}

clearpage
begin{flushleft}
hbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{raisebox{0pt}[dimtotop]{includegraphics[width=paperwidth]{example-image}}}%
}
end{flushleft}

section{A test section}
lipsum[4]

clearpage
noindentadjustimage{width=paperwidth,
lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5width-csname @totalleftmarginendcsname}, % adjustbox version v1.2 2019/01/04 provides this as 'pagecenter' key
set height=height-1in-voffset-topmargin-headheight-headsep}{example-image}

section{A test section}
lipsum[4]


end{document}


enter image description here






share|improve this answer













You need to raise the image into the upper margin. This can be done using raisebox. I used the layout package with the layout macro to display all length used by LaTeX to create the top of the page. The distance is 1in+voffset+topmargin+headheight+headsep. You need to use the optional argument to set the new height by subtracting that value from the original height, which is defined as height here. This also works if put into a header by simply removing headheight and headsep from the equation.



Of course you can also my adjustbox package to do all this with less code.



documentclass{article}
usepackage{lipsum}
usepackage{graphicx}
usepackage{adjustbox}


newcommand{dimtorightedge}{%
dimexprpaperwidth-1in-hoffset-oddsidemarginrelax}

newcommand{dimtotop}{%
dimexprheight-1in-voffset-topmargin-headheight-headseprelax}


begin{document}

clearpage
begin{flushleft}
hbox
{%
makebox[dimtorightedge]{}%
makebox[0pt][r]
{raisebox{0pt}[dimtotop]{includegraphics[width=paperwidth]{example-image}}}%
}
end{flushleft}

section{A test section}
lipsum[4]

clearpage
noindentadjustimage{width=paperwidth,
lap={textwidth}{-1in-hoffset-ifoddpageoddsidemarginelseevensidemarginfi+.5paperwidth-.5width-csname @totalleftmarginendcsname}, % adjustbox version v1.2 2019/01/04 provides this as 'pagecenter' key
set height=height-1in-voffset-topmargin-headheight-headsep}{example-image}

section{A test section}
lipsum[4]


end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 9 at 7:54









Martin ScharrerMartin Scharrer

200k45635818




200k45635818













  • Thanks Martin. That's exactly what I wanted. Seems like I had not fully understood the command raisebox. I was also not aware of the height command - I had overlooked the height command (and width, depth, as well) in the book 'The not so short introduction to LaTeX2e'.

    – Max
    Jan 9 at 8:15













  • @Max: height, width and depth are defined internally by raisebox when processing the length values. Also the adjustbox package does the same.

    – Martin Scharrer
    Jan 9 at 8:17











  • Oh you showed 2 ways of doing it. That's awesome. Thanks!

    – Max
    Jan 9 at 8:23











  • @Max: The adjustbox update from last week makes the horizontal adjustment easier, just replace the lap=... stuff with a simple pagecenter. I didn't used it yet, as not everyone might have the update yet.

    – Martin Scharrer
    Jan 9 at 8:27











  • Having learned from Martin's code, I also changed the dimtorightedge definition by replacing oddsidemargin withifoddpageoddsidemarginelseevensidemarginfi to add more flexibility. But I don't see any problem with the simpler definition without changing the default page layout.

    – Max
    Jan 9 at 8:39



















  • Thanks Martin. That's exactly what I wanted. Seems like I had not fully understood the command raisebox. I was also not aware of the height command - I had overlooked the height command (and width, depth, as well) in the book 'The not so short introduction to LaTeX2e'.

    – Max
    Jan 9 at 8:15













  • @Max: height, width and depth are defined internally by raisebox when processing the length values. Also the adjustbox package does the same.

    – Martin Scharrer
    Jan 9 at 8:17











  • Oh you showed 2 ways of doing it. That's awesome. Thanks!

    – Max
    Jan 9 at 8:23











  • @Max: The adjustbox update from last week makes the horizontal adjustment easier, just replace the lap=... stuff with a simple pagecenter. I didn't used it yet, as not everyone might have the update yet.

    – Martin Scharrer
    Jan 9 at 8:27











  • Having learned from Martin's code, I also changed the dimtorightedge definition by replacing oddsidemargin withifoddpageoddsidemarginelseevensidemarginfi to add more flexibility. But I don't see any problem with the simpler definition without changing the default page layout.

    – Max
    Jan 9 at 8:39

















Thanks Martin. That's exactly what I wanted. Seems like I had not fully understood the command raisebox. I was also not aware of the height command - I had overlooked the height command (and width, depth, as well) in the book 'The not so short introduction to LaTeX2e'.

– Max
Jan 9 at 8:15







Thanks Martin. That's exactly what I wanted. Seems like I had not fully understood the command raisebox. I was also not aware of the height command - I had overlooked the height command (and width, depth, as well) in the book 'The not so short introduction to LaTeX2e'.

– Max
Jan 9 at 8:15















@Max: height, width and depth are defined internally by raisebox when processing the length values. Also the adjustbox package does the same.

– Martin Scharrer
Jan 9 at 8:17





@Max: height, width and depth are defined internally by raisebox when processing the length values. Also the adjustbox package does the same.

– Martin Scharrer
Jan 9 at 8:17













Oh you showed 2 ways of doing it. That's awesome. Thanks!

– Max
Jan 9 at 8:23





Oh you showed 2 ways of doing it. That's awesome. Thanks!

– Max
Jan 9 at 8:23













@Max: The adjustbox update from last week makes the horizontal adjustment easier, just replace the lap=... stuff with a simple pagecenter. I didn't used it yet, as not everyone might have the update yet.

– Martin Scharrer
Jan 9 at 8:27





@Max: The adjustbox update from last week makes the horizontal adjustment easier, just replace the lap=... stuff with a simple pagecenter. I didn't used it yet, as not everyone might have the update yet.

– Martin Scharrer
Jan 9 at 8:27













Having learned from Martin's code, I also changed the dimtorightedge definition by replacing oddsidemargin withifoddpageoddsidemarginelseevensidemarginfi to add more flexibility. But I don't see any problem with the simpler definition without changing the default page layout.

– Max
Jan 9 at 8:39





Having learned from Martin's code, I also changed the dimtorightedge definition by replacing oddsidemargin withifoddpageoddsidemarginelseevensidemarginfi to add more flexibility. But I don't see any problem with the simpler definition without changing the default page layout.

– Max
Jan 9 at 8:39


















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%2f469300%2fhow-to-have-a-figure-touch-the-top-edge-of-the-page%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

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

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