• No results found

CTAN: http://www.ctan.org/pkg/multienv VC: https://bitbucket.org/martin_scharrer/multienv

N/A
N/A
Protected

Academic year: 2021

Share "CTAN: http://www.ctan.org/pkg/multienv VC: https://bitbucket.org/martin_scharrer/multienv"

Copied!
3
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

The multienv Package

Martin Scharrer martin@scharrer-scharrer.de

CTAN: http://www.ctan.org/pkg/multienv VC: https://bitbucket.org/martin_scharrer/multienv

Version v1.0 – 2012/05/20

Abstract

This package provides a multienv environment which allows to easily add multiple environments using a key=value syntax. Macros to define environments using this syntax are also provided.

1 Introduction

It is sometimes required to add multiple environments around some text in order to achieve a specific format. This macro simplifies this task especially for larger number of environments by allowing the environments and their arguments to be specified using a key=value syntax. A special add codekey is also provided to allow arbitrary code being added before and after the environment content.

Furthermore macros are provided to allow the definition of new environments which contain multiple other environments and code.

2 Usage

\begin{multienv}{henv=argi,hkey=valuei,...}

hcontent i

\end{multienv}

This environment takes a comma separated list of key=values where the keys are usually environment names and the values the arguments to this environment.

The environments are added around the content in the given order, i.e. the first environment is the most outer one and further environments are placed inside it.

At the moment only the following key is defined. Any other key is taken as an environment name.

add code={hcode beforei}{hcode after i}

This adds the given code before and after the content. Any code is permitted including macro argument tokens like ‘#1’.

1

(2)

henvironment i

henvironment i=hargumentsi

Any unknown key is taken as environment name and the value as argument(s) to the environment. If the value does not start with a brace ‘{’, bracket ‘[’ or angle ‘<’ it is taken as a single mandatory argument and is placed inside braces after the environment, otherwise it is placed unchanged after the environment:

henv i ⇒\begin{henv i} . . .\end{henv i}

henv i= ⇒\begin{henv i} . . .\end{henv i}

henv i=hargi ⇒\begin{henv i}{hargi} . . .\end{henv i}

henv i={hargi} ⇒\begin{henv i}{hargi} . . .\end{henv i}

henv i={harg1 i}{harg2 i} ⇒\begin{henv i}{harg1 i}{harg2 i} . . .\end{henv i}

henv i=[hoargi] ⇒\begin{henv i}[hoargi] . . .\end{henv i}

henv i=[hoargi]{hmargi} ⇒\begin{henv i}[hoargi]{hmargi} . . .\end{henv i}

henv i=<haargi> ⇒\begin{henv i}<haargi> . . .\end{henv i}

henv i=<haargi>{hmargi} ⇒\begin{henv i}<haargi>{hmargi} . . .\end{henv i}

etc.

\begin{multienv*}{henv=argi,hkey=valuei,...}

hcontent i

\end{multienv*}

This environment is identical to multienv but will apply the keys in the reverse order, i.e. every environment or code is added around the existing environments or code.

\newmultienvironment{henv namei}[hnumber of argsi][hdefault valuei]{henv=argi,...}

This macro defines a new environment like\newenvironmentdoes but uses the multienv syntax. The resulting environment will contain all given environments and code. The environment can have arguments including one leading optional argument. The arguments can be used as part of the keys and values. It should be noted that it is not allowed to use arguments in the second argument of the add codekey, because that code will be part of\end{henv namei}.

An error is raised if the environment already exists.

\renewmultienvironment{henv namei}[hnumber of argsi][hdefault valuei]{henv=argi,...}

Like\newmultienvironmentbut can be used to redefine existing environments.

It is is not relevant how the environment was defined previously. An error is raised if the environment does not already exist.

\providemultienvironment{henv namei}[hnumber of argsi][hdefault valuei]{henv=argi,...}

Like \newmultienvironment but the environment is only defined if it is not already defined. The environment is also not defined if there a macro with the same name exists.

2

(3)

3 Examples

The following multienv environment usage:

\begin{multienv}{enva,envb=arg,add code={code before}{code after}, envc=[oarg]{marg}}

content

\end{multienv}

is basically identical to:

\begin{enva}

\begin{envb}{arg}

code before

\begin{enc}[oarg]{marg}

content

\end{enc}

code after

\end{envb}

\end{enva}

Using multienv* the order the environments can be given in the opposite order:

\begin{multienv}{envc=[oarg]{marg},add code={code before}{code after}, envb=arg,enva}

content

\end{multienv}

The following code defines a centeredminipage environment which content is placed in a centered minipage which inner content is also centered.

\newmultienvironment{centeredminipage}[1]

{center,minipage=#1,add code={\centering}{}}

This is basically identical to:

\newenvironment{centeredminipage}[1]

{\begin{center}\begin{minipage}{#1}\centering}

{\end{minipage}\end{center}}

However actually the “plain” form of the environment are used, because it is more efficient and will also produce a correct error message if an incorrect \end macro is found:

\newenvironment{centeredminipage}[1]

{\begingroup\center\begingroup\minipage{#1}\centering}

{\endminipage\endgroup\endcenter\endgroup}

The groups are added because some environments require to be placed in a group by themselves, which is normally done by \begin and \end.

3

Referenties

GERELATEERDE DOCUMENTEN

Nu is verschillende malen de vraag gesteld 2) naar de wenselijkheid van het wettelijk regelen van verschillende organisatorische aspecten van de vroeg- hulp (b.v. recht van toegang

If you believe that digital publication of certain material infringes any of your rights or (privacy) interests, please let the Library know, stating your reasons. In case of

As indicated above, the analysis of the operation of khul‘ in daily life formed a important part of my research since I believe it fills a gap in the anthropological study of

37 This draft of the new marriage contract included the following stipulations: agreement as to the ownership of the furniture in the marital abode and to whom it should devolve

They included: an amendment of the “khul‘ law” in May 2000 through which the previously abolished article (which stated that men who do not provide for their families were liable

In the meantime, we see how a group of fallahin (peasants from Upper Egypt), including the uncle of Tarik, is watching on television how a woman tells the interviewer that she

\setmydatebynumber{number}{yearcount}{monthcount}{daycount}: Sets the counters yearcount, monthcount, and daycount to values, which corresponds to the

The $ sign is masked to avoid keyword extension by Subversion inside this source file.... It