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

10
votes
1answer
2k views

verbatim useable with a newenvironment definition?

I'm trying to create a simple newenvironment allowing me to display source code in a verbatim text block with a caption, numbering etc. The solution I'm after is with the in-built LaTeX verbatim ...
9
votes
4answers
480 views

How to redefine an environment to produce no output?

I am using the verbatim environment with \begin{verbatim} XXXX \end{verbatim} I would like the option of redefining the verbatim environment so that nothing between \begin{verbatim} and ...
8
votes
2answers
148 views

Customise counters, cross references to environments

I would like to make cross references to own defined counter on environments. So far I have tried the following, \documentclass{book} \newcounter{entryc}[subsection] ...
8
votes
3answers
17k views

LaTeX enumerate - bold item with non-bold text

I'm trying to customize the environment enumerate where the \item is bold but the text is not bold. What I've tried is (at the suggestion of one of the google-results): \let\origitem\item ...
7
votes
3answers
17k 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 ...
7
votes
1answer
1k 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
519 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
518 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
2k views

Extra intervals before and after flushright environment

I am preparing questionnaire template in LaTeX. I have the following code (simplified): \documentclass{article} \begin{document} \framebox{\parbox{4cm}{ \textbf{3. How often do you have a ...
5
votes
1answer
850 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: ...
1
vote
2answers
188 views

Understanding the arguments in newtheorem e.g. \newtheorem{theorem}{Theorem}[section] [duplicate]

I would like to understand what the arguments following \newtheorem are e.g.: \newtheorem{theorem}{Theorem}[section] \newtheorem{lemma}[theorem]{Lemma} ...
1
vote
1answer
8k 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 ...
11
votes
3answers
1k 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*}} ...
9
votes
2answers
180 views

Continuance of environment

I am using an continuous example in my text, but I don't know how to do define the corresponding nice environment. I am using the amsmath and ntheorem package and defined my own example-environment: ...
8
votes
1answer
535 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
295 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
1k 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
973 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
161 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
133 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
293 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
411 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
402 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} ...
66
votes
3answers
30k views

What's the difference between the environments quote and quotation?

On meta, I've found the disscussion {quotation} and {quote}, but it doesn't answer my question. When should I use the environment quote? When quotation?
14
votes
1answer
361 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 ...
19
votes
5answers
31k 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 ...
17
votes
2answers
24k 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
300 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
212 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 ...
22
votes
5answers
735 views

Typesetting hashtags with natural syntax

I'm using an online conversation in my document and I've made an environment to use for it. The thing is, there are many #hashtags in each post (that I'd like to color appropriately). To make it ...
15
votes
4answers
568 views

How do I use the boxed theorem name as a QED symbol

I'm wondering if there's a relatively simple way to achieve a result similar to the following: In particular, I'd like to be able to assign names and/or numbers to theorems/lemmas/propositions and ...
13
votes
4answers
9k views

Defining my own proof environment?

How would I define a proof environment that is basically used with \begin{proof} some proof here \end{proof} and it would be equivalent to: \paragraph{Proof:} some proof here \hfill \box ?
11
votes
2answers
314 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
3answers
4k views

How to make LaTeX ignore the contents of an environment?

I would like to make a \todo command and environment whose behavior changes depending whether I define a command \showtodos. A basic \todo command is simple to write: ...
11
votes
2answers
1k 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?
10
votes
1answer
929 views

What is the purpose of putting \newenvironment, \newcounter in a document class?

In exam.cls, I saw the following codes which I don't understand how do they function in the document class (exam): \newcounter{question} \newcounter{partno} \newcounter{subpart} ...
10
votes
2answers
545 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 ...
9
votes
1answer
3k 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
3answers
896 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
892 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
226 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 ...
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
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
1k 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 ...