Page LayoutImage next to Chapter Heading

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
thomas1981
Posts: 2
Joined: Tue Mar 20, 2012 5:15 pm

Image next to Chapter Heading

Post by thomas1981 »

Hello,

When typesetting a new chapter in the "book" document class with the command \chapter{Introduction}, I get the following output
Chapter X
Introduction
What I want to obtain is the following:
## Chapter X
## Introduction
where the dash marks represent some space where I would like to place a picture, for example with the \includegraphics command.

Can someone explain me how to do that without altering the default style of chapter (just to move it a bit on the right in order to place the image)?

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Image next to Chapter Heading

Post by localghost »

Could be done by the titlesec package.

Code: Select all

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[explicit,raggedright]{titlesec}

\newlength{\picsep}   % Separation between picture and heading
\setlength{\picsep}{0.05\textwidth}
\newlength{\picwidth}   % Width of the picture
\setlength{\picwidth}{0.2\textwidth}
\titleformat{\chapter}[block]
{\normalfont\huge\bfseries}
{\parbox{\picwidth}{\rule{\linewidth}{1.5\linewidth}}}   % replace \rule{…}{…} with your picture
{\picsep}
{\begin{minipage}{\dimexpr\textwidth-\picsep-\picwidth}\chaptertitlename\ \thechapter\\[20pt]\Huge\bfseries\filright#1}[\end{minipage}]

\begin{document}
  \chapter{Chapter title over two lines}
    Text
\end{document}
The comments in the above code should help to get things right. The new length registers can be used for adjustments. The width of the {minipage} environment) will always be exactly 1\textwidth.


Best regards and welcome to the board
Thorsten
thomas1981
Posts: 2
Joined: Tue Mar 20, 2012 5:15 pm

Re: Image next to Chapter Heading

Post by thomas1981 »

Thank you Thorsten!
That's exactly what I needed :)
TotteKarlsson
Posts: 1
Joined: Mon Aug 11, 2014 10:48 pm

Image next to Chapter Heading

Post by TotteKarlsson »

Hello,
I'm quite new to tex and I'm trying to use the above example but I am having problem getting it working.

I do want the graphics to occupy 65% of the page on where the Chapter heading occur, optimally positioned to the right of the Chapter# and Title text.

Also importantly, a different graphics for each chapter will be used.
The current code:

Code: Select all

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[explicit,raggedright]{titlesec}
\usepackage{graphicx}

\newlength{\picsep}   % Separation between picture and heading
\setlength{\picsep}{0.05\textwidth}
\newlength{\picwidth}   % Width of the picture
\setlength{\picwidth}{0.2\textwidth}
\titleformat{\chapter}[block]
{\normalfont\huge\bfseries}
{\parbox{\picwidth}{\includegraphics[width=0.5\textwidth]{periodicTable.jpg}}}   % replace \rule{…}{…} with your picture
{\picsep}
{\begin{minipage}{\dimexpr\textwidth-\picsep-\picwidth}\chaptertitlename\ \thechapter\\[20pt]\Huge\bfseries\filright#1}[\end{minipage}]

\begin{document}
  \chapter{Chapter title over two lines}
    Text 
\end{document}
produces this output:
chapter-heading.png
chapter-heading.png (49.48 KiB) Viewed 8805 times
I have been fiddling around with the code, but seem not to be able to figure out how to get it done properly. Any help greatly appreciated!
tk
Last edited by Stefan Kottwitz on Tue Aug 12, 2014 12:57 pm, edited 1 time in total.
Post Reply