Graphics, Figures & Tablescolored lines

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
izza
Posts: 3
Joined: Tue Mar 23, 2010 2:58 pm

colored lines

Post by izza »

Hi there,

I'm writing a report in/with Latex and I need to draw some colored lines like:

---------------xxxxxxxxxxxx

xxxxxxxxxxxxxxx------------


where ------ is a red line and xxxxx blue

And it would be perfect if it can be thick lines also...

Does anyone have an idea how to create this in/with latex. Is there some kind of package that I would need?

I really appreciate all kinds of help!

Regards
A.

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

colored lines

Post by gmedina »

Hi,

in the following example code I defined two new commands to draw colored lines with variable thickness. The code explains the syntax:

Code: Select all

\documentclass{article}
\usepackage{xcolor}

\makeatletter
% \cvhrulefill{<color>}{<thickness>}
\newcommand*\cvhrulefill[2]{%
  \leavevmode\color{#1}\leaders\hrule\@height#2\hfill \kern\z@\normalcolor}
% \crule{<color>}{<width>}{<thickness>}
\newcommand*\crule[3]{%
  \color{#1}\rule{#2}{#3}\normalcolor}
\makeatother

\begin{document}

\cvhrulefill{red}{2pt}\cvhrulefill{red}{2pt}\cvhrulefill{blue!40}{2pt}

\cvhrulefill{blue}{3pt}\cvhrulefill{red}{1pt}\cvhrulefill{green}{4pt}
\cvhrulefill{gray}{6pt}

\crule{orange}{4cm}{.4pt}\crule{purple}{4cm}{.4pt}\crule{yellow}{4cm}{.4pt}

\vspace*{1cm}

\crule{olive}{4cm}{2cm}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
izza
Posts: 3
Joined: Tue Mar 23, 2010 2:58 pm

Re: colored lines

Post by izza »

Hi

Thank you very very very much!!! :D :D :D
Post Reply