LaTeX/C3/Defining-Colours-and-Environments/English
Title of the script: Defining Colours and Environments
Authors: Ambika Vanchinathan
Keywords: LaTeX, xcolor package, colorbox, fcolorbox, definecolor, rowcolors, RGB, CMYK, HTML color, video tutoria
| Visual Cue | Narration |
| Slide 1
Title Slide |
Welcome to this spoken tutorial on Defining Colours and Environments. |
| Slide 2
Learning Objectives |
In this tutorial, we will learn to:
|
| Slide 3
System Requirements To record this tutorial, I am using:
|
To record this tutorial I’m using the following setup. |
| Slide 4
Pre-requisites |
To follow this tutorial, learners should have basic knowledge of LaTeX. |
| Slide 5
Code files The following code file is required to practice this tutorial: 1. xcolor-eg.tex This file is provided in the Code Files link of this tutorial page. |
The following code file is required to practice this tutorial.
This file is provided in the Code Files link of this tutorial page. |
| Let us get started.
Let us see how to get a framed box with colours. | |
| Uncomment the line 27
Run the code show the output |
Uncomment line 27.
Run the code. Output shows a boxed text in yellow and some random text in it. |
| Highlight:
line 27 |
The command \colorbox takes 2 arguments.
The first one is the colour of the box. And the second one is the text that is inside the box. |
| Uncomment the line 31
Run the code show the output |
Uncomment line 31.
Run the code. Output shows some text enclosed in a box. The color of the frame is red and box filled with green colour. |
| Highlight:
line 31 |
This command creates a framed box.
The command \fcolorbox takes 3 arguments. First one is the frame colour. Second one is the colour to be filled in the box. Third is the actual text that goes inside the framed box. |
| Uncomment the line 33
Run the code show the output |
Uncomment line 33.
Run the code Output shows another framed box with a black frame filled with lime colour. |
| Let us now see how to define new colours. | |
| Uncomment the line 35
Highlight: line 35 Point to the defined colour. Show the options shown as reference, |
Uncomment line 35.
The command \definecolor defines a new colour. It takes 3 arguments. 1. name of the new colour to be defined 2. model – rgb, cmyk etc. 3. colour definition – Each number shows how much red, green, and blue are mixed to get a new color. Here we have defined a colour called myOrange in rgb model . Complete options are given at the end of the TeX file for reference. |
| Let us apply the newly defined myOrange colour to the text. | |
| Uncomment the line 37
Run the code and show the output |
Uncomment line 37
Run the code Output shows the text in myOrange colour from the section heading onwards. |
| Let’s see how to colour the rows in the table. | |
| Comment line 4
Uncomment the line 41, 5 Run the code and show the output |
Comment line 4.
Uncomment lines 5 and 41. Run the code. The output shows the table rows in yellow and lime colour. |
| Highlight:
lines 41, 5 |
The command \rowcolors painted the rows in the table.
We also need to load the package xcolor with [table] option to use this command. The \rowcolors command takes 3 arguments: 1. The row number from which coloring should begin 2. color for odd-numbered rows 3. color for even-numbered rows Here, it starts colouring from row 1. Odd rows are colored in yellow and even rows in lime colour. |
| Point to the table. | Let us see how changing the starting row number affects the coloring. |
| Comment the line 41
Uncomment the line 43 Run the code and show the output |
Comment line 41
Uncomment line 43. Run the code. Output shows colouring of the rows starting from the second row. |
| Highlight line 43 | Here the \rowcolors command is defined with argument 2.
This means the coloring starts from row two. The first row is not coloured. |
| Slide 6
Summary In this tutorial, we have learnt:
|
With this we come to the end of this tutorial.
Let us summarise. |
| Slide 7
Assignment |
As an assignment,
Define a new colour maroon using the RGB model mixing as (0.9, 0, 0). Use it as text colour of the document |
| Slide 8
Thank you |
Thank you for joining |