Generalhow can I make my own environment

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
yotama9
Posts: 61
Joined: Thu Sep 24, 2009 2:59 pm

how can I make my own environment

Post by yotama9 »

Hi guys.

Where can I find a guide of how can I create my own environment which is based on an exciting one?

Please note, I don't want to change the old environment but I simply want to create new one which "inherit" some of the old one properties?

Thanks.

Yotam

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

how can I make my own environment

Post by localghost »

Just propose targeted questions. Explain which environment you mean and which of its properties you want to change.

I'm not aware of a special guide but every book about LaTeX basics should describe how to create own environments. If you want to know more about existing environments take a look at the class files or the latex.ltx kernel file. Its sources are described in source2e (web search for source2e.pdf).


Best regards
Thorsten
yotama9
Posts: 61
Joined: Thu Sep 24, 2009 2:59 pm

how can I make my own environment

Post by yotama9 »

I want to modify a little bit the equation environment:
  • I want to shift the numbering of the equation one line down.
  • I want to be able to refer to the equation with it's own counter using \cref I read some documentation about it.
  • I think I need it to be a float because I want latex to move to the next page the equation if the number and the equation are separated.
Here is what I'm using now:

Code: Select all

%Creating counter for reactions
\newcounter{reaction}[chapter]
\newenvironment{reaction}[1]{
    \refstepcounter{reaction}
    \begin{equation*}
     \ce{#1}
    \end{equation*}
    \begin{flushright}
      reaction (\arabic{section}.\arabic{reaction})
    \end{flushright}
    }
  {}
yotama9
Posts: 61
Joined: Thu Sep 24, 2009 2:59 pm

Re: how can I make my own environment

Post by yotama9 »

bump

localghost. I know you placed a solution to this in another thread but I don't want to blindly paste parts but rather to understand our code.

Yotam
Post Reply