{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)

8
votes
2answers
173 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
101 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
121 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
82 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
126 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
158 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
145 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
145 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
2answers
561 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
49 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
75 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
252 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
1answer
239 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
259 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
170 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
126 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
306 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
855 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
48 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
165 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
37 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
130 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
278 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
4answers
946 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}} ...
4
votes
1answer
54 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
140 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
127 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
565 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
537 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
433 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
594 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
3answers
81 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
63 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
77 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
55 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
131 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
83 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} ...
3
votes
0answers
148 views

Vertical line in matrix in gauss package [duplicate]

I am currently using the gauss package since I need to write out operations between my matrices. However I am unable to add a vertical line to the far right in my augmented matrices. The gauss package ...
3
votes
1answer
140 views

Using tabu/tabularx inside xparse NewDocumentEnvironment

My question seems very similar to this, but with tabu instead of tabular*. In fact, switching the options in that example causes the failure I see here. \NewDocumentEnvironment {trace} {} {% ...
3
votes
0answers
69 views

Using catcode in conjunction with lstnewenvironment and lstinputlisting

(This is related to Injecting text contained in file into custom environment, but I was asked to put this in a separate post) From regular expression in listings the following code works fine : ...
3
votes
1answer
71 views

Remove the automatic generation of number?

I looked for my past thread which can be found here: Create a two column static small box the solution i accepted was the truefalse environment. My question is, how will i remove the automatic ...
3
votes
1answer
80 views

How to indent part of line to certain amount?

I apologize if this is a basic question, but I'm new to LaTeX and typography in general, and I'm not sure how to articulate my question properly. I have a document which looks like this: ...
3
votes
1answer
151 views

Defining macros based on environment

Right now, I have two macros, \intersects and \union, that simply point back to \cap and \cup respectively. Unfortunately, to have nice typesetting in display-like environments, I need to use \bigcap ...
3
votes
1answer
333 views

Difference in behaviour between tabular and flushleft environments

In response to my earlier question the following working code has been provided: \documentclass{article} \usepackage{showframe} \begin{document} \hfill \begin{tabular}{l@{}} some text\\ some other ...
3
votes
1answer
173 views

afterpage + list = missing \item

I'm trying to use the afterpage package to automatically insert text at the top of each page (please see my other question Section reminders at the top of each page?) but I'm having trouble. ...
3
votes
3answers
2k views

Redefine \arraycolsep for particular environments

How do I change \arraycolsep for a single environment? E.g., I have \arraycolsep set so that the white spacing on either side of "=" in the equation array environment is not excessive. However, this ...