View Single Post
Old 03-24-2010, 10:41 AM   #37
Sweetpea
Grand Sorcerer
Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.Sweetpea ought to be getting tired of karma fortunes by now.
 
Sweetpea's Avatar
 
Posts: 9,707
Karma: 32763414
Join Date: Dec 2008
Location: Krewerd
Device: Pocketbook Inkpad 4 Color; Samsung Galaxy Tab S6
I've been playing with my HTML and LaTeX templates a bit. My application to transform the HTML to LaTeX was getting way too complicated (to reflect all classes I had defined in my CSS...). I decided to see if I could simplify things.

First, if I add a new class, I don't want to update my transformer. Second, I wanted to clean up my transformer a bit.

So, I checked out the \newenvironment command. That thing is powerful!

For example:

A lot of books have a dedication, so I created a standard class (default implemented in my CSS) "dedication"

<p class="dedication">Thanks to you all!</p>

I first replaced that in my transformer with:

Code:
\ \\[1cm] \noindent Thanks to you all!
But I wasn't really happy with how it looked, wich meant I had to change my code. While I do have a template which is the basis for my final book.

So, I changed the code of my transformer to:

Code:
\begin{dedication}
Thanks to you all!
\end{dedication}
and added in my template:

Code:
\newenvironment{dedication}
  {\ \\[1cm] \noindent
    \begin{adjustwidth}{1.5em}{1.5em}
  }
  {\end{adjustwidth}}
Now I can change it whenever I want, without having to open Visual Studio...



Well, I made it even a bit more flexible... I made a list of classes, put that in a different (text) file, and all those classes map to either an internal environment (such as center) or a custom made one. Now, if I make a new class, I only have to add it to that text file and add a definition to my template.
Sweetpea is offline   Reply With Quote