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

6
votes
1answer
766 views

lstlisting in a newenvironment

I have a problem with the lstlisting package. I want to define an \newenvironment with one obligatory parameter, which will be the caption name for the lstlisting. I will also have other lstlisting ...
6
votes
1answer
434 views

How to use figure inside a exercise environment?

Trying to use figure inside an Exercise environment (exercise.sty) gives me "LaTeX Error: Not in outer par mode." Example: \documentclass{article} \usepackage[]{exercise} \begin{document} ...
5
votes
1answer
383 views

Splitting a command syntax across a \newenvironment definition

This question is a direct follow-up to the question Can a \newcommand Definition Contain Braces as Substitution Text? I asked yesterday. The following example is once again a counter-intuitive one, ...
5
votes
1answer
814 views

How to create an index for custom environments?

I have defined a custom script environment, and would like to include an index in the output listing all scripts with their titles. How can I create such an index? The custom environment looks like: ...
4
votes
3answers
10k views

Footnote in tabular environment

It seems as if footnotes would have only a problem with the table environment but in my minimal example non of those answers Footnotes in Tabulars? Footnote in table seem to work for the tabular ...
11
votes
3answers
978 views

How to pass an optional argument to an environment with verbatim content?

This is an attempt to make clear what happened in this question of xport (now deleted, sorry). The now deleted question included code that tried to make my answer to this question of xport work for ...
10
votes
3answers
3k views

Defining a command for amsmath's align environment

I'd like to define a shorthand command for \begin{align*} and \end{align*}. When I write \newcommand{\ba}{\begin{align*}} it works fine. But when I write \newcommand{\ea}{\end{align*}} ...
8
votes
1answer
445 views

Vertical spaces above and below longtabu

This is, in a way, a follow-up-question to New table-environment, spaces and enclosing { } in a new environment, which has already been answered conveniently by @egreg. Please compile this MWE to ...
8
votes
2answers
2k views

What are alternatives to block?

I use \begin{block} ... \end{block} to describe formalization of some notions, and I want to write some examples under it. I still would like to stick to the structure of a block (one part for title ...
7
votes
3answers
3k views

lrbox in \newenvironment

I cannot make lrbox work if put within a \newenvironment. I'll explain with an example. If I write: \documentclass{article} \newsavebox{\mybox} \begin{lrbox}{\mybox} ...
5
votes
1answer
273 views

Suppressing remarks when not needed

I have written some remarks in some of my works that are somewhat informal and repetitive in nature (mainly for my own clarification). I was wondering if there is a way of suppressing them when I ...
5
votes
2answers
964 views

Environment with first paragraph in bold and no pagebreaks

I would like to setup a new environment which typesets the first paragraph in boldface, the following paragraphs in normal text, and with (possibly) no pagebreaks between the first paragraph and the ...
5
votes
2answers
938 views

How to redefine (via `environ` package) the `pmatrix` environment?

I want to redefine the pmatrix environment provided by the amsmath package (and changed by the mathtools package) for adding good-looking delimiters. The code is below: \documentclass{article} ...
4
votes
1answer
4k views

Removing vertical space before and after tabbing environment

When I write \begin{tabbing} \hspace{4in}\= \kill % set up two tab positions {\bf University }, {\it City, NW} \> PhD, Physics (2007-2011)\\ \end{tabbing} Methodology and numerical ...
3
votes
1answer
136 views

Environment for two columns with lstlistings

In order to reduce copy-pasting, I want to create an environment that will produce a two-column table with headers and two listings in different languages, like below: \begin{tabular}{l l} Python ...
1
vote
1answer
101 views

naming argument and optional-argument for \def, \newcommand and newenvironment

I know how to create a new command or an environment. I think it will much better if I can specify name of the arguments. For example in framebox command and array environment below, we know exactly ...
1
vote
1answer
246 views

minted Environment Inside minipage Environment

I am having to use the minted environment inside a minipage environment quite often in my document. I wanted to write a new environment for doing this, but since minted isn't designed to be included ...
1
vote
1answer
6k views

LaTeX Error: Environment table undefined

When I try to compile a latex file, I get the following error: LaTeX Error: Environment table undefined. I think the line that is causing the problem is: \begin{table} Does anybody know how I can ...
1
vote
1answer
382 views

How to create a new counter for an a new environment that is in sync with subsections

I want to create an example environment with a counter which will be in sync with my subsections. So I'll have: subsection 3.2 lemma 3.2 example 3.2 example 3.3 lemma 3.3 subsection ...
1
vote
1answer
367 views

Why does pdfLaTeX fail when I try to use `begin{lstlisting}` inside a user-defined environment?

I'm having trouble with the listings package. I can't compile the following minimal example through pdfLaTeX: \documentclass[a4paper, 11pt, twoside, openright, english]{memoir} \usepackage{listings} ...
15
votes
5answers
777 views

How to put a star (or other symbol) in sections that are “special” (difficult, optional, etc)?

I'm currently writing a book, and I'd like some of the sections to be clearly marked as "difficult" or "optional". Not only sections, but also exercises (I'm using the exercise package) and theorems ...
14
votes
1answer
277 views

Theorem with separate tikz environments for header and body

My initial question: I'm writing my lecture notes in LaTeX and used some customized theorem environments with amsthm so far. Now I wanted to redesign those theorems with help of tikzpicture. That's ...
16
votes
5answers
28k views

Beamer block environment without title

Is it possible to create a customised beamer block environment that only has a body and not a title? For example, I wish to typeset the following quote within a coloured block so that it stands out ...
15
votes
2answers
20k views

Example environment?

I was wondering if there is any formal environment for specifying 'examples' through out the text. If not, which environments do you recommend?
8
votes
2answers
295 views

How to make a wrapper for the figure and table environments.

I am familiar with the newenvironment command, but I was wondering, how do I carry on the parameters that are used between [ ], i.e [bht!]? I want to make a newfig and a newtab environment that will ...
6
votes
2answers
2k views

Create a \lstnewenvironment that creates named listings

I am using the \lstnewenvironment to format a set of code listings in my document. \lstnewenvironment{code} {\lstset{language=haskell, basicstyle=\small\ttfamily, numbers=left, ...
26
votes
1answer
208 views

Why is there no \provideenvironment?

LaTeX2e provides a \providecommand but there is no \provideenvironment which defines an environment only if it (or a macro with the same name) was not defined before. Is there a specific reason why it ...
20
votes
2answers
900 views

Reliable code for automatic \noindent after specific environments?

This question led to a new package: noindentafter There are a number of environments which I never want to follow up with an indented paragraph. itemize, enumerate, theorem, definition, etc. I ...
11
votes
2answers
264 views

How can I define a new minted environment with optional arguments?

I have the following mwe: % arara: pdflatex: { shell: true } % arara: pdflatex: { shell: true } \documentclass{article} \usepackage{minted} \usepackage{listings} \usepackage{caption} ...
11
votes
2answers
992 views

How do I define new environments, and why would I want to?

I've read about defining new, custom environments that can be used like \begin{thisismyown} % do some funky stuff \end{thisismyown} How do I define thisismyown, and why would I want to?
8
votes
3answers
698 views

An environment for setting \emergencystretch locally

The following environment, copied from this website about dealing with overfull hboxes, allows one to change the \tolerance parameter for just the paragraph(s) it encloses: ...
8
votes
3answers
734 views

How to make an environment star Exercise?

I want to create an environment star Exercise, but I can not. Please help me. \documentclass{book} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsmath} ...
8
votes
3answers
223 views

How to use named variables with one environment

Just after there is one code which has been proposed to me in this site. Instead of using \begin{MyFrame}[1.5cm][2pt][1.3cm][blue][2][8ex], I would like to use something more friendly like ...
7
votes
3answers
3k views

Change the font of the block quote?

Sorry if this is a duplicate, but I can't find the right way of doing this. I want to redefine my quote and quotation commands to use a different font. My main font is Linux Libertine O (I am using ...
7
votes
1answer
972 views

Vertical space before and after custom environment

I've created custom environment with these commands: \usepackage{relsize} \newcounter{annotation} \def\theannotation{\arabic{annotation}} \newenvironment{annotation} ...
6
votes
3answers
1k views

Number mhchem reactions and create a \listofreactions

Is there a way to create an environment for reactions defined with mhchem that behaves similarly to equation in terms of numbering the reactions (including a \nonumber command)? Can I get a list of ...
5
votes
3answers
1k views

Defining a new LaTeX environment for numbered two-column proofs

I'm trying to write up problem sets for my programming languages class, and I want to create an environment for a certain style of proof. Proofs in this style will have two columns, with numbering on ...
27
votes
6answers
1k views

Is it possible to automatically enumerate sentences in LaTeX?

1.0.1 Is it possible to automatically enumerate sentences in LaTeX? 2.0.1 I want to thoroughly work through and criticize a longer text. 2.0.2 To facilitate quoting, I would like to typeset the text ...
12
votes
3answers
4k views

How do I generate a check-list?

Similar to the itemize or description environments I would like to have a check-list environment, with neat boxes on the right side, that I may check or uncheck. I guess I'm not the first having this ...
11
votes
1answer
281 views

New list environment: automatic enumeration with “a posteriori” format

This is a follow-up question to Nested enumerate labels with parent label appended plus a single set of enclosing parentheses First and foremost, sorry for my English, I'm learning it currently. ...
9
votes
1answer
135 views

Suggestions for an automatic taxonomy environment

Background In this site there are excellent examples of How to draw up a hierarchical tree diagram for taxonomic classification of several groups but often you must show only the position of a ...
9
votes
1answer
221 views

how to redefine \begin{align*} … \end{align*} to \begin{eqnarray*} … \end{eqnarray*}

Scientific word insists in generating displayed math using \begin{align*} ... \end{align*} and htlatex has a bug in that it does not generate bit mapped images in this case. The fix that I found ...
9
votes
2answers
743 views

Using an environ environment with \newenvironment

I want to use an environment defined with NewEnviron from environ in another environment definition: \documentclass{article} \usepackage{environ} \NewEnviron{inner}[1]{% \textbf{#1:} \BODY } ...
8
votes
1answer
100 views

Why is this lettrine being bumped into the margin?

Consider the MWE from an earlier question: \documentclass{article} \usepackage{lettrine} %\usepackage{fontspec} %\defaultfontfeatures{Ligatures={Historical}} ...
8
votes
1answer
2k views

Defining my own description environment

I need help writing my own description environment. The only thing I want to change is the appearance of description label. I can achieve what I want universally just fine with the following bit in ...
8
votes
1answer
2k views

How to define a new environment with a fancy box (tikz) around sample source-code (listings)?

This is what I want to do: \documentclass{beamer} \begin{document} \begin{frame}[fragile]{Frame 1} Some \structure{Python} code here: % I want to define a new "pythoncode" environment, so ...
7
votes
2answers
467 views

Environment to allow line breaks at `,` in math mode

I find the question and accepted answer to Allowing line break at ',' in inline math mode? very useful, BUT I would like to make an environment (e.g. "allowbreaks"} out of it. The problem is that I'm ...
7
votes
1answer
264 views

Looking for a better code for my \newcommand

While preparing my lecture notes, I decide to create a command, possibly a new environment, that highlights when I am presenting a worked example. I came up with the following code. The code does ...
7
votes
1answer
497 views

Adding something automatically to every paragraph in an environment

I'd like to know if it's possible to have something added automatically to any paragraph in a given environment. I use LaTeX mostly for doing fill-in-the-blank worksheets at the school where I work. ...
5
votes
2answers
77 views

Collecting contents of LaTeX environment

I have the following for collecting contents of an environment and printing them later, it works but for my real task i want to use the environ package because i need to be able to have access to ...