GeneralCreate a fancy section heading layout?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
idaham
Posts: 21
Joined: Wed May 21, 2008 4:30 pm

Create a fancy section heading layout?

Post by idaham »

Hi!
I have a bit of a problem and wonder if anyone can help me.. I found a very nice document layout, like the one found at "http://www-ra.phys.utas.edu.au/~jsteven ... s_p103.jpg" (The chapter number is large, colored and above the chapter title). This layout is meant for the documentclass "book". (The code for the style is found at "http://www-ra.phys.utas.edu.au/~jsteven ... style.html"). I wonder if anyone knows how to get the same style for the documentclass "article"? Since there are no chapters in articles, I'm trying to get the style to work on section headings instead, i.e. the section heading should be the same with the section number large and colored, above the section title. I've tried for hours without result! =( Does anyone have some tips how to change the section headings to some fancy layout, I'd be really grateful! Cheers!
/Ida

Recommended reading 2024:

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

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

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

Create a fancy section heading layout?

Post by localghost »

The code uses a package called psboxit, which was developed for LaTeX2.09 and therefore must be considered obsolete. A similar style could be achieved by combining the quotchap and the titlesec package. After reading the related documentations, feel free to ask further questions.


Best regards
Thorsten
idaham
Posts: 21
Joined: Wed May 21, 2008 4:30 pm

Create a fancy section heading layout?

Post by idaham »

localghost wrote:The code uses a package called psboxit, which was developed for LaTeX2.09 and therefore must be considered obsolete. A similar style could be achieved by combining the quotchap and the titlesec package. After reading the related documentations, feel free to ask further questions.


Best regards
Thorsten
Hi Thorsten, and thank you for helping me out!
I've tried to look in quotchap.sty to get some ideas, but since I'm a newbie when it comes to LaTex, I didn't completely succeed.. I've written my own sty-file to do what I want, and it looks like:

Code: Select all

\RequirePackage[calcwidth]{titlesec}
\RequirePackage{color}

\definecolor{seccol}{rgb}{0,0.8,0.3}
  
\titleformat{\section}[hang]{\sffamily\bfseries}
{\color{seccol}\Huge\thesection}{0pt}{\linebreak\huge\raggedleft}[{\titlerule[0.5pt]}]
I load this sty-file into a document and the section heading looks quite nice! Although, the section number is too small (\Huge here), and when I try to change it to something bigger, using ex. \fontsize it doesn't work! I've also tried to change the font of the section number (number only, not the section title!), without any success... Should I write those commands somewhere around where I added the \color command? Thanks!
Ida
Hamed
Posts: 4
Joined: Sat May 24, 2008 1:27 pm

Re: Create a fancy section heading layout?

Post by Hamed »

Hi all,
I have a question, using the section format posted above how do you make colorbox around the section name?

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

Create a fancy section heading layout?

Post by localghost »

Hamed wrote:Hi all,
I have a question, using the section format posted above how do you make colorbox around the section name?

Thanks
At the moment I have no idea. But perhaps you find some useful hints in the documentation of the titlesec package.


Best regards and welcome aboard
Thorsten
idaham wrote:[...] Although, the section number is too small (\Huge here), and when I try to change it to something bigger, using ex. \fontsize it doesn't work! I've also tried to change the font of the section number (number only, not the section title!), without any success... Should I write those commands somewhere around where I added the \color command? [...]
Just replace the \Huge command in your definition of the section format by the following sequence, which works fine for me.

Code: Select all

\fontsize{36}{42}\selectfont
As you can see, you only have forgotten the \selectfont command to activate the new font size. The second argument of the \fontsize command is the interlinear space and should have about additional 20% of the first value.
idaham
Posts: 21
Joined: Wed May 21, 2008 4:30 pm

Create a fancy section heading layout?

Post by idaham »

idaham wrote:[...] Although, the section number is too small (\Huge here), and when I try to change it to something bigger, using ex. \fontsize it doesn't work! I've also tried to change the font of the section number (number only, not the section title!), without any success... Should I write those commands somewhere around where I added the \color command? [...]
Just replace the \Huge command in your definition of the section format by the following sequence, which works fine for me.

Code: Select all

\fontsize{36}{42}\selectfont
As you can see, you only have forgotten the \selectfont command to activate the new font size. The second argument of the \fontsize command is the interlinear space and should have about additional 20% of the first value.[/quote]

Hello again Thorsten and thanks for all your help!
I've tried your suggestion with \fontsize{36}{42}\selectfont, which works fine. The problem is that I want an even bigger size, say 100 or something. The size doesn't seem to get any larger than 40. The weird thing is that this command is the same as the one defined in quotchap.sty:

Code: Select all

\usefont{T1}{\@defaultcnfont}{b}{n}\fontsize{150}{130}\selectfont%
    \color{chaptergrey}
which makes the chapter number very large! Apparently this size is defined... How come is doesn't work for my section number?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Create a fancy section heading layout?

Post by Stefan Kottwitz »

Hi Ida,

try the fix-cm package:

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage{fix-cm}
\begin{document}
\fontsize{100}{120}\selectfont Huge text
\end{document}
Stefan
LaTeX.org admin
idaham
Posts: 21
Joined: Wed May 21, 2008 4:30 pm

Create a fancy section heading layout?

Post by idaham »

Stefan_K wrote:Hi Ida,

try the fix-cm package:

Code: Select all

\documentclass[a4paper,10pt]{article}
\usepackage{fix-cm}
\begin{document}
\fontsize{100}{120}\selectfont Huge text
\end{document}
Stefan
Stefan, you're a lifesaver!
This worked perfectly! I don't know how long I've been trying to get it to work without succeeding... Thank you so much! Cheers,
Ida

PS. If anyone is interested in this section style, here's the code for my sty-file:

Code: Select all

\RequirePackage[calcwidth]{titlesec}
\RequirePackage{color}
\usepackage{fix-cm}

\definecolor{seccol}{rgb}{0,0.8,0.3} % This is a kind of greenish color... you can define the exact color you want here!
\titleformat{\section}[hang]{\sffamily\bfseries}{
\fontsize{100}{100}\selectfont\color{seccol}\thesection}{0pt}{\linebreak\huge\raggedleft}[{\titlerule[0.5pt]}]
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Create a fancy section heading layout?

Post by localghost »

You should get the desired result with any postscript font, too. Just try some font packages from the CTAN Catalogue.
Post Reply