Hi Everyone, how are you.
I'm trying to make since two days a new environment it order to include explicit
examples in a document. The problem is that I would like to make a list of all these environments that I have included and the result is a chaotic horizontal list.
I'm sure that you can help me. Again.
Please could you tell me what's wrong and how can I fix it?
Thank you very much.
PD: I have attached the .tex (compiling on latex->ps->pdf is required)
General ⇒ Trying to creating a new environment with its own list
Trying to creating a new environment with its own list
- Attachments
-
- nuevosentornos.tex
- (3.26 KiB) Downloaded 238 times
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
Trying to creating a new environment with its own list
The addition of an example to your LoL should take place outside the shaded environment. Moreover it seems that the \par command need to be added to ech line. Modify your declaration as follows.
I didn't test it so there's no guarantee.
Best regards
Thorsten
Code: Select all
\newenvironment{ejemplo}[1]{%
\refstepcounter{ejem}
\begin{shaded}
\textbf{Ejemplo. \theejem. #1}\par
}{%
\end{shaded}
\addcontentsline{lol}{ejemplo}{\protect\numberline{\theejem} #1\par}
}
Best regards
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Re: Trying to creating a new environment with its own list
Thanks but I think that I have now 9 errors. So there's some kind of mistake in this code. This time I'm very lost with the solution of my problem. I would thank any help.
PD: I include de new example (with logalghost's modification)
PD: I include de new example (with logalghost's modification)
- Attachments
-
- nuevosentornos2.tex
- (3.42 KiB) Downloaded 257 times
Last edited by jonysatie on Sat Oct 10, 2009 1:32 am, edited 1 time in total.
Trying to creating a new environment with its own list
Hi,
the problem comes from this:
the problem comes from this:
no parameters can be used explicitly in the ending part of the definition of a new environment. In some time (when I take a look at the code you posted) I can give you some possible solution.localghost wrote:...
\newenvironment{ejemplo}[1]{%
\refstepcounter{ejem}
\begin{shaded}
\textbf{Ejemplo. \theejem. #1}\par
}{%
\end{shaded}
\addcontentsline{lol}{ejemplo}{\protect\numberline{\theejem} #1\par}
}...
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Re: Trying to creating a new environment with its own list
Ohh thanks .. So I will be waiting for your post.
There's a few helpfull Tips here: http://www.golatex.de/newenvironment-t3238.html
There's a few helpfull Tips here: http://www.golatex.de/newenvironment-t3238.html
Trying to creating a new environment with its own list
Hi again,
the following code can be used as a starting point to obtain what you desire:
Please, feel free to adapt my example according to your needs.
the following code can be used as a starting point to obtain what you desire:
Code: Select all
\documentclass[12pt]{memoir}
\usepackage{xcolor}
\usepackage{amsmath}
\definecolor{shadecolor}{gray}{0.9}
\newcounter{ejem}
\numberwithin{ejem}{section}
\makeatletter
\newcommand\l@ejemplo{\@dottedtocline{1}{2em}{3em}}
\makeatother
\newlistof{listofexamples}{lol}{Lista de Ejemplos}
\newenvironment{ejemplo}[1]{%
\refstepcounter{ejem}
\begin{shaded}
\addcontentsline{lol}{ejemplo}{\protect\numberline{\theejem} #1}
\textbf{Ejemplo \theejem. #1}\par}
{\end{shaded}}
\begin{document}
\listofexamples
\chapter{veamos}
\section{lalalala}
\begin{ejemplo}{mosh}
Hola me llamo Jonathan y soy feliz adem\'as de entusiasta.
\end{ejemplo}
\subsection{Veamos de nuevo}
\begin{ejemplo}{mish}
Hola me llamo Jonathan y soy feliz adem\'as de entusiasta y contento.
\end{ejemplo}
\section{lalalala}
\begin{ejemplo}{lin}
Hola me llamo Jonathan y soy feliz.
\end{ejemplo}
\begin{ejemplo}{hallo}
Hola me llamo Jonathan y soy m\'as feliz a\'un.
\label{ejem:jojo}
\end{ejemplo}
Ver ejemplo \ref{ejem:jojo}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Trying to creating a new environment with its own list
Ohh that's indeed what I was searching for.
Could you explain just a little what this commands mean.
And thank you. This solved the problem.
Bye
Could you explain just a little what this commands mean.
Code: Select all
\makeatletter
\newcommand\l@ejemplo{\@dottedtocline{1}{2em}{3em}}
\makeatother
Bye
Trying to creating a new environment with its own list
Of course. The \l@ejemplo command does the actual typesetting of the entries in the newly defined LoL (List of Examples); in my example code I used the \@dottedtocline command to control the entries layout.jonysatie wrote:...
Could you explain just a little what this commands means.
Code: Select all
\makeatletter \newcommand\l@ejemplo{\@dottedtocline{1}{2em}{3em}} \makeatother
The \@dottedtocline command has the following syntax:
Code: Select all
\@dottedtocline{level}{indent}{numwidth}{text}{page}
level: the nesting level of the entry.
indent: the total indentation from the left margin.
numwidth: the width of the box that contains the number.
text: the text to be used following the number of the entry.
page: the page number in the document in which the entry will actually appear.
In my example I used only the first three parameters, since the other two will be picked automatically when using the \addcontentsline command.
The \makeatletter and \makeatother commands make possible to use the special character @ in the definition or redefinition of new commands or environments.
You are welcome!jonysatie wrote:...
And thank you. This solved the problem.
Bye
1,1,2,3,5,8,13,21,34,55,89,144,233,...