GeneralChange the color of linerule

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
davefulton
Posts: 8
Joined: Wed May 05, 2010 8:36 pm

Change the color of linerule

Post by davefulton »

Dear LaTeX gurus,

I was wondering if anybody could help me change the color/thickness of a section underline.
I have used \usepackage{titlesec}

and have used the code

\titleformat{\section}{\Large\raggedright}{}{0em}{}[\titlerule]
%Tweak the top margin
\addtolength{\voffset}{-1.3cm}

How do I change the color/thickness?

I tried

\titleformat{\section}{\Large\raggedright}{}{0em}{}[\titlerule[0.8pt]
]

From what it says in literature but to no avail. It doesn't compile!

Any help would be greatly appreciated

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Change the color of linerule

Post by gmedina »

Hi,

Try something along these lines:

Code: Select all

\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}

\titleformat{\section}
  {\Large\raggedright}
  {}{0em}{}[{\color{red}\titlerule[8pt]}]

\begin{document}

\section{Test section}

\end{document}
As you can see, the optional argument of \titlerule controls the height of the rule; the color can be changed locally with the \color command
1,1,2,3,5,8,13,21,34,55,89,144,233,...
davefulton
Posts: 8
Joined: Wed May 05, 2010 8:36 pm

Re: Change the color of linerule

Post by davefulton »

You are a star! Thank you. While I've got your attention. I am using a piece of code

\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Fontin Sans}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}

where I can select the font from my local library. However when I use certain fonts it doesn't produce the Small Caps style from the \sc declaration. The Small Caps fonts are there as I have checked them against the ones that work. Is there any reason you can think of off the top of your head?

Thank you so much for your help
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Change the color of linerule

Post by frabjous »

That's XeLaTeX code for fontspec. You should be clear you're using XeLaTeX.

I think sometimes fontspec has trouble identifying the right small caps font to use; probably has something to do with the fonts themselves. But fontspec has commands for specifying the exact font to use. I don't have Andale Mono or Gill Sans installed right now, but for Fontin Sans, the following works for me:

Code: Select all

\documentclass[letterpaper]{article}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[SmallCapsFont={Fontin Sans Small Caps}]{Fontin Sans}
\begin{document}

This is \textsc{small caps}.

\end{document}
(You don't need to repeat Mapping=tex-text if you're already set it to default to that...)

But if we're going to continue on this line, we should start a new thread with an appropriate subject line.
Post Reply