Difference between revisions of "LaTeX/C3/newenvironment-in-LaTeX/English"
m |
Nancyvarkey (Talk | contribs) |
||
Line 13: | Line 13: | ||
|- | |- | ||
| style="border:0.75pt solid #000000;padding:0.176cm;"| Slide | | style="border:0.75pt solid #000000;padding:0.176cm;"| Slide | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| Welcome to the spoken tutorial on creating | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| Welcome to the spoken tutorial on creating '''new environments '''in '''LaTeX'''. |
|- | |- | ||
Line 21: | Line 21: | ||
* create or define new '''environments''' to get customized output. | * create or define new '''environments''' to get customized output. | ||
* redefine the existing '''environments'''. | * redefine the existing '''environments'''. | ||
− | |||
− | |||
|- | |- | ||
Line 31: | Line 29: | ||
# You should also have knowledge of '''compiling '''and producing a '''PDF output '''in '''LaTeX'''. | # You should also have knowledge of '''compiling '''and producing a '''PDF output '''in '''LaTeX'''. | ||
# If not, please go through the relevant '''LaTeX''' spoken tutorials on this website. | # If not, please go through the relevant '''LaTeX''' spoken tutorials on this website. | ||
− | |||
− | |||
|- | |- | ||
Line 40: | Line 36: | ||
* '''Ubuntu Linux 14.04''' operating system | * '''Ubuntu Linux 14.04''' operating system | ||
* '''TeXWorks 0.5''' | * '''TeXWorks 0.5''' | ||
− | |||
− | |||
|- | |- | ||
| style="border:0.75pt solid #000000;padding:0.176cm;"| slide: '''New Environment''' | | style="border:0.75pt solid #000000;padding:0.176cm;"| slide: '''New Environment''' | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| Just like | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| Just like '''new commands,''' we can define '''new environments.''' |
Line 55: | Line 49: | ||
|- | |- | ||
| style="border:0.75pt solid #000000;padding:0.176cm;"| slide: '''New Environment''' | | style="border:0.75pt solid #000000;padding:0.176cm;"| slide: '''New Environment''' | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| New environment is a variation of executing few existing commands put together in a sequence. | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| '''New environment''' is a variation of executing few existing commands put together in a sequence. |
− | Ensure that the custom '''environment''' you create, is not an already existing '''LaTeX | + | Ensure that the custom '''environment''' you create, is not an already existing '''LaTeX environment'''. |
|- | |- | ||
Line 67: | Line 61: | ||
− | Here the '''start commands''' are | + | Here the '''start commands''' are executed whenever the environment starts. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | And '''end commands''' are executed whenever the environment ends. | ||
|- | |- | ||
Line 82: | Line 73: | ||
| style="border:0.75pt solid #000000;padding:0.176cm;"| Pause the tutorial at this point. | | style="border:0.75pt solid #000000;padding:0.176cm;"| Pause the tutorial at this point. | ||
− | Download and unzip the files provided in the | + | Download and unzip the files provided in the '''Code Files''' link below the player. |
− | + | ||
− | Code Files link below the player. | + | |
|- | |- | ||
Line 91: | Line 80: | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| You will see some LaTeX | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| You will see some '''LaTeX |
− | code given in the file newEnv.tex | + | code''' given in the file '''newEnv.tex''' |
|- | |- | ||
Line 124: | Line 113: | ||
\end{document} | \end{document} | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| We will copy and paste the first block of code from this file into our newly opened tex file. | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| We will copy and paste the first block of code from this file into our newly opened '''tex''' file. |
Line 167: | Line 156: | ||
|- | |- | ||
| style="border:0.75pt solid #000000;padding:0.176cm;"| | | style="border:0.75pt solid #000000;padding:0.176cm;"| | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| Now, we will see how to use '''parameters''' in the '''environments'''. |
|- | |- | ||
| style="border:0.75pt solid #000000;padding:0.176cm;"| slide: '''New environment with parameters''' | | style="border:0.75pt solid #000000;padding:0.176cm;"| slide: '''New environment with parameters''' | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| New environment with parameter is defined as | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| '''New environment''' with parameter is defined as |
'''<nowiki>\newenvironment{environment name}[parameters]{start commands}{end commands} </nowiki>''' | '''<nowiki>\newenvironment{environment name}[parameters]{start commands}{end commands} </nowiki>''' | ||
− | |||
− | |||
− | |||
|- | |- | ||
Line 219: | Line 205: | ||
\end{document} | \end{document} | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| We will copy the next block of code from our downloaded code file |
− | + | ||
+ | and paste it into our new '''teX''' file. | ||
Line 246: | Line 233: | ||
|- | |- | ||
| style="border:0.75pt solid #000000;padding:0.176cm;"| Point to the exact line as per narration | | style="border:0.75pt solid #000000;padding:0.176cm;"| Point to the exact line as per narration | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| * We use it as '''“\begin{bluetext}{My text in blue}”''' | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| |
+ | * We use it as '''“\begin{bluetext}{My text in blue}”''' | ||
* and the text, | * and the text, | ||
* and then '''“\end{bluetext}”''' | * and then '''“\end{bluetext}”''' | ||
− | |||
− | |||
|- | |- | ||
Line 281: | Line 267: | ||
− | It’s quite similar to newenvironment. | + | It’s quite similar to '''newenvironment'''. |
|- | |- | ||
Line 311: | Line 297: | ||
\end{document} | \end{document} | ||
− | | style="border:0.75pt solid #000000;padding:0.176cm;"| We will copy and paste the last block of code from our downloaded file into our newly opened tex file. | + | | style="border:0.75pt solid #000000;padding:0.176cm;"| We will copy and paste the last block of code from our downloaded file into our newly opened '''tex''' file. |
Line 338: | Line 324: | ||
− | The text given within '''\begin{itemize}''' and''' \end{itemize}''' | + | The text given within '''\begin{itemize}''' and''' \end{itemize}''' should be |
− | + | ||
− | should be | + | |
* converted to large size | * converted to large size | ||
* and centered according to our definition | * and centered according to our definition | ||
− | |||
− | |||
|- | |- | ||
Line 363: | Line 345: | ||
* '''renewenvironment''' | * '''renewenvironment''' | ||
+ | |- | ||
+ | | style="border:0.75pt solid #000000;padding:0.176cm;"| slide: '''Assignment''' | ||
+ | | style="border:0.75pt solid #000000;padding:0.176cm;"| Create an environment '''itemizecolor, ''' | ||
+ | which takes the color (red, blue, yellow, green) as input | ||
− | + | and creates a list in that color. | |
− | + | ||
− | + | ||
|- | |- |
Revision as of 16:48, 18 September 2015
Title of script: New Environments
Author: Ambika Vanchinathan
Keywords: New environment, renewenvironment, define environments in LaTeX, \newenvironment, \renewenvironment, video tutorial
Visual Cue | Narration |
Slide | Welcome to the spoken tutorial on creating new environments in LaTeX. |
Slide:Learning Objectives | This tutorial will help the learners to
|
Slide: Pre-requisites | To follow this tutorial,
|
Slide:System Requirements | To record this tutorial, I am using
|
slide: New Environment | Just like new commands, we can define new environments.
|
slide: New Environment | New environment is a variation of executing few existing commands put together in a sequence.
|
slide: New environment | The syntax to define a new environment is
\newenvironment{environment name}{start commands}{end commands}
And end commands are executed whenever the environment ends. |
Open the TeXWorks editor | Let us open the TeXWorks editor. |
Pause the tutorial at this point.
Download and unzip the files provided in the Code Files link below the player. | |
Switch to the code file
|
You will see some LaTeX
code given in the file newEnv.tex |
(copy/paste the following in TeXWorks)
\usepackage{color} \newenvironment{bluetext} {\begin{center}\color{blue}} {\end{center}} \begin{document} This text is outside the new environment. This text is outside the new environment. This text is outside the new environment. \begin{bluetext} Testing to see whether this text is in blue colour. \end{bluetext} some more text \end{document} |
We will copy and paste the first block of code from this file into our newly opened tex file.
|
Let’s try to understand the program. | |
Point to the exact line as per narration | Here \newenvironment{bluetext}
means that we are defining a new environment called bluetext. |
Point to the exact line as per narration | Here in the definition we center the text and colour it with blue using
{\begin{center}\color{blue}} {\end{center}}
|
Save as newEnv.tex | Save the file as newEnv.tex |
Compile >> Point to the pdf output | Let us compile and see the output.
|
<<PAUSE>> | |
Now, we will see how to use parameters in the environments. | |
slide: New environment with parameters | New environment with parameter is defined as
\newenvironment{environment name}[parameters]{start commands}{end commands} |
open a new file in TeXWorks | Let’s open a new file in TeXWorks. |
Switch to the code file | Now switch to our downloaded code file. |
(copy/paste the following)
\usepackage{color} \newenvironment{bluetext}[1] {\begin{center}\color{blue} \textbf{\textit{#1}}\\[12pt] } {\end{center}} \begin{document} This text is outside the new environment. This text is outside the new environment. This text is outside the new environment. \begin{bluetext}{My text in blue} Testing to see whether this text is in blue colour. \end{bluetext} some more text \end{document} |
We will copy the next block of code from our downloaded code file
|
Point to the exact line as per narration
|
Let us understand the code now.
|
Point to the exact line as per narration | We have just added
\textbf{\textit{#1}}\\[12pt] to the code given for the environment without parameter |
Point to the exact line as per narration |
|
Save file as newEnvp1.tex | Save the file as newEnvp1.tex |
Compile >> point to the pdf | Now compile and see the output. |
<<PAUSE>> | |
We shall see the renewenvironment now. | |
slide: renewenvironment
|
renewenvironment is used to change or overwrite the existing environment.
\renewenvironment{env}{start commands}{end commands}
|
Open a new tex file. | Once again, we will open a new tex file. |
(copy/paste the following)
\renewenvironment{itemize}{\begin{center}\large }{\end{center}} \begin{document} This text is outside the new environment. This text is outside the new environment. This text is outside the new environment. \begin{itemize} Text inside itemize
\end{itemize} \end{document} |
We will copy and paste the last block of code from our downloaded file into our newly opened tex file.
|
Point to the exact line as per narration | Let us understand the code.
|
Recall that the itemize environment creates a list according to the original definition. | |
Point to the exact line as per narration | Let’s see the usage.
|
Save code to renewEnv.tex | Let us save the file as renewEnv.tex and compile the tex file. |
Point to the PDF output | Observe the output. |
Slide: Summary | To summarise, we have learnt
|
slide: Assignment | Create an environment itemizecolor,
which takes the color (red, blue, yellow, green) as input and creates a list in that color. |
Slide: Acknowledgement | The video at the following link summarises the Spoken Tutorial project.
Pls watch it. |
Slide | The Spoken Tutorial Project Team :
Conducts workshops using spoken tutorials and Gives certificates to those who pass an online test For more details, please write to us. |
Slide | Spoken Tutorial Project is funded by the NMEICT, MHRD, Government of India.
Thanks for joining. |