{environments} is for general questions related to (La)TeX environments. For questions about environment subcategories like {lists}, {quoting} environments, or {floats} use the appropriate tag instead.

learn more… | top users | synonyms (3)

2
votes
2answers
330 views

Time calculation for task reports

Consider this MWE: \documentclass{article} \newenvironment{dayreport}{\begin{tabular}{ll}\hline Task & Time\\\hline}{\hline\end{tabular}} \newcommand{\task}[2]{#1 & #2\\} \begin{document} ...
2
votes
1answer
388 views

How to hide a verbatim-like environment in another environment?

I cannot find a good title to express my question. Therefore, please parse the following code first. Minimal Code \documentclass[dvips,dvipsnames,cmyk,table]{book} ...
16
votes
1answer
376 views

What is the difference between \newenvironment and \newenvironment*?

I vaguely seem to recall reading that \newenvironment* gives better spacing than \newenvironment, but I don't recall any details and I can't seem to find a reference by searching. What is the ...
16
votes
1answer
568 views

How to define a starred version of an environment in LaTeX

I am interested in defining a new environment in LaTeX that has a starred version. How is this done?
11
votes
2answers
147 views

Is it safe to abbreviate \begin{foo}…\end{foo} with something like \bfoo … \efoo

Can I safely do this: \newcommand\bfoo{\begin{foo}} \newcommand\efoo{\end{foo}} where foo is a standard LaTeX environment? Probably the verbatim environment breaks, but others as well? That way one ...
10
votes
4answers
1k views

Use column-separator & (ampersand) inside \newenvironment

I'd like to define a grammar environment which basically wraps a tabular environment. Inside the grammar environment I'd like to use an environment called production to insert rows. Example: ...
9
votes
3answers
130 views

How can I collect the contents of a LaTeX environment in a macro without the grouping?

It's a bit of a long story as to why I need to do this, but please bear with me. I have a fairly complicated custom class which expects documents to begin with a command: \coverandabstract{Abstract ...
8
votes
2answers
179 views

How to make a new environment behave like an existing environment?

I wish to create an environment that behaves alternately like a footnote, an endnote or a comment (i.e. hidden). For starters i've defined an environment "note" thus: \newenvironment{note} { ...
8
votes
2answers
102 views

Define a command so that it is only active within the document environment

I would like to configure a custom command so that it only affects the document environment. Because the command changes a number of catcodes, it has to be included after the begin{document} tag in ...
8
votes
1answer
3k views

Footnote in block statement

I have a presentation to make, and in this I present a quote in a block, like this: \begin{block}{Quote headline} Some truly great words some man made before me. \end{block}\footnote{And this is ...
7
votes
1answer
130 views

Creating an example environment structured exactly like amsthm's proof environment

I want to create an environment for examples that is structured exactly like the \begin{proof}...\end{proof} environment, i.e. starting with an italic "Example.", continuing in the same line and ...
7
votes
1answer
1k views

Twocolumn part in document

I'd like to stretch long lists into two or more columns. Like: Some single-column text. Lorem 4. Sit Ipsum 5. Amet Dolor Another single-column text. Or: Some ...
6
votes
1answer
97 views

Macro, new command or new environment for code?

I am using the listings package to typeset code. I have defined a custom style using \lstdefinestyle{verbo} and then typeset code in a lstlisting environment as in the following MWE. ...
6
votes
2answers
132 views

Using an expanded macro for optional environment argument

I'd like to open an environment, passing the content of a macro to the optional arguments. Up to now I tried different approaches using \expandafter, however I could not get the expected behaviour. ...
6
votes
2answers
162 views

Getting the first line of an environment

as the title suggests, I'm looking for a way to get the first (printable) line in an environment. My first naive attempt (ignoring the printable requirement) was something like this: ...
6
votes
1answer
147 views

Environment makes unnecessary page break

I have a problem with user-defined environments in LaTeX. Even though the content of an environment seems to fit, sometimes LaTeX makes an unneccessary page break after all. Here is my MWE: ...
6
votes
3answers
147 views

String parsing macro fails within custom cite command of biblatex?

I am trying to use the same string parsing macro as in String parsing macro fails within a minipage environment?; but this time in context of biblatex - and I'm having similar problems, I guess. ...
6
votes
1answer
213 views

Custom environment move to end of chapter

I have written a custom example environment for formatting mathematical worked examples. These are currently included in the sections they are related to, however are sometimes looking a bit ...
6
votes
2answers
573 views

etoolbox: environment hooks in boolean switch

What did I wrong, that the following does not work here: (Edit: I mixed up the true and false parts, but I don't want to change the code, because the answers refer to this in a way confusing one.) ...
5
votes
1answer
55 views

how to use conditional to define different \begin and \end environment at compile time

I just need little help on the syntax for this. I am using tex4ht, and I get an error when I use empheq for the align environment. I want to build this TeX file both in pdflatex and htlatex. I ...
5
votes
2answers
81 views

An environment for fixed figures

I am trying to create an environment that I can use to include "figures" within a framed environment. Because floats aren't allowed inside framed environments, I want to create a new environment ...
5
votes
2answers
268 views

How to color certain commands/environments?

My goal is to achieve colorings in the output document, that are similar to the syntax highlighting I use in my editor, so switching between the editing and viewing the document becomes easier on the ...
5
votes
4answers
1k views

Defining a new environment extending a verbatim environment

Why is it not possible to define a new environment that extends a verbatim environment? Consider, e.g.: \documentclass{article} \newenvironment{myverbatim}{\tiny\begin{verbatim}}{\end{verbatim}} ...
5
votes
1answer
246 views

Savebox with \bgroup/\egroup doesn't work in beamer (for environment)

This works: \documentclass{article} \newsavebox{\mybox} \begin{document} \savebox{\mybox}\bgroup This is a test.\egroup\usebox{\mybox} \end{document} But this fails (Missing } inserted. at the ...
5
votes
1answer
269 views

How to prevent pagebreak for a custom environment?

I use the following custom environment emailHeader and macros to format an email header (credits belong to egreg). \definecolor{emailHeaderBackground}{RGB}{225,225,225} ...
5
votes
1answer
175 views

Newenvironment not cursive

I created a new envrionment and it looks good, but I want to distinguish between normalfont and cursive font, so here is my code: \newshadetheorem{beispiele}{Beispiel} ...
5
votes
1answer
127 views

Customize environment “proof”

I need to create (or customize) an environment "proof" that has the option to explain after the word 'proof' the name of the theorem (or environment) along with its automatic numbering of the theorem ...
5
votes
2answers
315 views

Redefining \enumerate using \let - why does it behave this way and what can I do to bypass it?

The following code produces a result, that I find quite strange: \documentclass{article} \let\origenumerate\enumerate \renewenvironment{enumerate}{\begin{origenumerate}}{\end{origenumerate}} ...
5
votes
1answer
866 views

Using versions environment tags inside a new environment definition

I just found out about the versions package here and am interested in using it to hide solutions in a problem set document. Recall that, to create versions block, in the preamble, you need ...
4
votes
2answers
55 views

Trouble defining new environment with embedded gather

I looked at the solution to How do I embed a gather environment within a custom environment? But things are still not working for me: MWE: \documentclass[border=6pt]{standalone} ...
4
votes
4answers
167 views

Running numbers for comments

I wish to have comment 1, comment 2 as running numbers, and for each reviewer I want to restart the running number, is there a good way to achieve this? Following is how the pdf currently looks, and ...
4
votes
1answer
39 views

How to generalize a solution with \NewEnviron to \RenewEnviron (error: \env@proof@save@env undefined)

This question is a follow-up from Solution environment via true/false switch where Ian helped me to define a solution environment which can be hidden. I tried it as well for a proof environment, but ...
4
votes
2answers
135 views

Two kinds of equation labels within one paper

I have looked high and low for an answer to the following (including on this site, Google, etc.) without success, and I hope someone may be able to answer it (and if it is a repeat of something ...
4
votes
1answer
298 views

Converting string to number

I am trying to write an environment which provides (some of) the functionality parallel environment through tabular syntax so that the following two code snippets would give equivalent results: ...
4
votes
1answer
55 views

Bad interaction between keycommand and environ?

I suspect the keycommand and environ packages are not playing nicely together, because the following code gives an error. Can anybody explain what's going on? \documentclass{article} ...
4
votes
1answer
141 views

Class Design: Environment vs. Macro

I have seen What are the consideration when choosing either newcommand or newenvironment? but I think this is a little more specific. If it's a duplicate, then so be it. If the second part of the ...
4
votes
2answers
128 views

Nesting custom `xparse` environments

I've defined two simple environments with xparse. Problem is when I try to nest todominute environment inside minutes environment: \documentclass[a4paper, 10pt]{article} \usepackage{polski} ...
4
votes
1answer
570 views

Onecolumn till end of page in twocolumn mode

I know about using the widetext environment for setting text in onecolumn mode and the multicols package for effortless switching between one- and twocolumn mode, but I think this is not too great if ...
4
votes
2answers
552 views

Is there an “identity” (or “no-op”) environment that simply uses its contents unaltered?

In the functional programming paradigm, it is common to have functions accept other functions as parameters. This paradigm can be followed in LaTeX, too: A macro can accept parameters which themselves ...
4
votes
1answer
439 views

String parsing macro fails within a minipage environment? [closed]

I am trying to work with a string parsing macro, found in the answer of TeX capacity exceeded while parsing a date string - TeX - LaTeX. Basically, I have strings num01, num02... num09 - from these, ...
4
votes
1answer
601 views

Using TikZ along with picture environment

Please see my examples: picture After TikZ \documentclass{article} \usepackage{color} \usepackage{tikz} \usepackage[english]{babel} \begin{document} \begin{tikzpicture} \path ...
4
votes
2answers
141 views

Errors passing the contents of a LaTeX environment to a macro

First of all, I'm sorry if this is a bit of an obvious newbie question, I've tried reading as many of the posts on here about doing this sort of thing, but was unable to get any of them to work. I'm ...
4
votes
2answers
2k views

\bgroup and \egroup?

So I've been looking to expand on the following bit of code (a hack to not screw up the margins when using oversized figures): \noindent\makebox[\textwidth]{% \begin{tabularx}{1.5\textwidth}{XX} ...
3
votes
1answer
121 views

Xparse macro not working when \obeylines is in effect

This is the most strange and hard-to-debug situation I have encountered in latex. When \obeylines is in effect, it seems that macros with optional argument defined by xparse will have some trouble. ...
3
votes
3answers
91 views

Horizontal space in a new environment after \label{}

Why is the horizontal space inserted in the following mwe? \documentclass{scrartcl} \usepackage[american]{babel} \usepackage{environ} \usepackage{amsthm} % proof environment \makeatletter ...
3
votes
1answer
66 views

How to prevent page break in the last three lines of an environment?

I want to create an environment, thats content should not allowed a page break in the last three lines of the last paragraph. If the last three lines of the text inside the environment reach the ...
3
votes
1answer
81 views

How to expandafter an environment?

I have the following problem: I want to create a beamer presentation and introduced a new environment using xparse. The environment has one optional argument (+ two mandatory). Now I want to create an ...
3
votes
1answer
64 views

Nomenclature not being assigned proper page number

The following is my MWE: \documentclass[12pt,twoside]{report} \usepackage[intoc]{nomencl} \newenvironment{preliminary}% {\pagestyle{plain}\pagenumbering{roman}}% {\pagenumbering{arabic}} ...
3
votes
1answer
133 views

Indicator at end of theorem

I'm writing a text with some very long theorem-environments in it and I find the italicised theorems visually not pleasing when they are rather longish. So I'm using the definition theorem style most ...
3
votes
1answer
84 views

Using savebox around the BODY of environ

I tried to use a \savebox around the \BODY macro of \NewEnviron. Can I keep the linebreaks somehow (they are gone, in the MWE)? \documentclass{article} \usepackage{environ} \newsavebox{\mybox} ...