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

15
votes
2answers
379 views

How to make AUCTeX ignore syntax highlighting within environment

I have a problem with syntax highlighting in the Emacs editor using AUCTeX. The problem occurs in particular with the Verbatim environment from the fancyvrb package. Consider the following code: ...
14
votes
9answers
813 views

Looking for a more appropriate version of \cases

Often-times I find myself wanting to write something like, That is, a vertical brace followed by a table consisting of three columns, the first and the last are math, aligned where-ever I like, and ...
14
votes
3answers
824 views

Extracting the contents of text in a specified environment into a new file

Imagine I have a complete latex file and I want to extract only the text that appears in a specified environment (i.e., within a custom hypothesis environment) For example: \begin{document} ... Lots ...
14
votes
3answers
1k views

Defining commands that are scoped to a particular environment

Is it possible to define commands in a separate namespace so that they only work within a particular environment? For example, can I create a package named foo that defines a foo environment and a ...
14
votes
2answers
213 views

Dash in Environment Name

I'm trying to make a verbatim environment called "my-environ" \documentclass{article} \usepackage{fancyvrb} \DefineVerbatimEnvironment{myenviron}{Verbatim}{numbers=left,frame=lines,label=My ...
14
votes
2answers
409 views

Automatically add quotes

I would like to create a new environment which will behave similar to quote, but with quotes added. I tried something like this: ...
14
votes
2answers
1k views

mdframed and wrapfig

Before starting the question, I apologize for the large pictures. I had to use some long text to demonstrate the problem. To generate something like: I used the following command: ...
14
votes
2answers
390 views

Is it possible to make an image gallery with tikz images?

I create many images with TikZ and I would like to make an image gallery. It should look like this: The gallery should put the image in front of a (gray) background resize the image to a maximum ...
14
votes
4answers
488 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 ...
14
votes
1answer
310 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 ...
14
votes
1answer
413 views

Is there a way to have an “empty” environment to merely limit scope of declarations?

I am fairly new to LaTeX, so I apologize if this is a beginner question, but I have not found a good way to query for it otherwise. I have observed that when I use an environment like ...
14
votes
2answers
200 views

Repeating environment contents twice

I'm writing a document where I have many code blocks like so: \begin{align} d = \sqrt{ (x'-x)^2 } \end{align} \begin{minted}{latex} d = \sqrt{ (x'-x)^2 } \end{minted} So the first line renders ...
13
votes
4answers
286 views

What are the consideration when choosing either newcommand or newenvironment?

The first time I learnt LaTeX, I thought \newcommand properly fits for inline mode and \newenvironment for displayed mode. Later I noticed it is not correct. So the question is What is the rule of ...
13
votes
3answers
8k views

Creating a new environment with one optional argument

I want to create a new environment with one optional argument in LaTeX. Here is what I used: \newenvironment{argument}[1][]{% \par \noindent \textbf{Argument#1:} \noindent} {} When there is no ...
13
votes
4answers
348 views

\let and sneaky redefinitions that are wrappers for the original macro: is there a similar thing for environments?

Let's say I am using some macro \foo that almost does what I want, but I actually want to add space either side of the output of \foo. I can do the following: \let\tempfoo\foo ...
13
votes
1answer
651 views

Typesetting a definition

My current set up for type setting definitions is \newenvironment{definition}[1][Definition:]{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}} ...
13
votes
2answers
827 views

Format a verbatim paragraph

How can I format a verbatim paragraph? I.e. break, fill and join input lines to produce globally balanced output with the lengths of each line approaching the target \textwidth as closely as possible. ...
13
votes
2answers
2k views

How do you define your environment such as to use […] for some parameter(s)?

In an environment, say \newenvironment{whatever}[3]{...}{...} you instantiante it (if that's the word for it in LaTeX) by \begin{whatever}{first}{second}{third} ... \end{whatever} But how do ...
13
votes
3answers
2k views

Hide custom environment content based on boolean

I have a custom environment which adds some text around its content, but I also want it to be able to show or hide its contents depending on a boolean. I have tried doing the following: ...
13
votes
2answers
163 views

Filecontents and newenvironment issue

I need to write some inlined code on an external file, then load it with listings. I would like to define a new environment, but if I do, filecontents does not save the first line of code (see MWE): ...
13
votes
2answers
2k views

Define an “escape underscore” environment

I am writing a text document in LaTeX where I need a lot a words with underscores: foo_bar_1, more_bar_2_long_expression_3. I know about the underscore package, but for some reason the [strings] ...
13
votes
2answers
4k views

Split-like environment inside cases environment

I'd like to have a cases environment with some cases that are too long to fit on one line. I tried this: \begin{cases} \begin{split} long expression \\ second line of long expression ...
13
votes
2answers
2k views

Displaystyle fractions in a system of equations

I'm trying to define an environment to use with equations' systems. So far, the best solution was \newenironment{eqsys}{\begin{equation}\begin{cases}}{\end{cases}\end{equation}} but I noticed that ...
13
votes
4answers
8k 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 ?
13
votes
1answer
138 views

How can I undefine an environment?

How can I undefine an environment? This is how to undefine a command: \newcommand\foo \makeatletter \let\foo\@undefined \makeatother I need to undefine the spacing environment from the setspace ...
13
votes
2answers
494 views

How to turn off an environment (e.g. tikzpicture) for faster draft compiling

I'm currently writing my thesis and have been looking for ways to speed up compile time. I can shave off a lot of time by using draft mode so that images aren't processed, but I have several TikZ ...
13
votes
2answers
499 views

Centering text on a page

I'll try to illustrate what I want to accomplish. I want an enviroment/page style for poems that works like this -- the title (if present) is placed in the title placeholder (purple). The body of the ...
13
votes
2answers
671 views

Combine minted and tcolorbox

I have the idea to combine minted with tcolorbox. At first, I have created my own minted environments: \newminted[mycsharp]{csharp}{tabsize=2,fontsize=\footnotesize} ...
13
votes
1answer
136 views

When is it safe to assume that \begin{<env_name>} and \<env_name> do the same thing

I've been under, apparently, the misapprehension that if you have defined an environment called <env_name> then \begin<env_name> and \<env_name> accomplish the same thing. But ...
12
votes
4answers
354 views

Opaque error messages given by common environments

This is a public-interest question. The title of the question Why does this error keep popping up even though I clearly fixed it? poignantly expresses a fundamental truth of LaTeX usage: sometimes ...
12
votes
2answers
297 views

What is the problem with nested environments using \BODY (environ package)?

This question led to a new package: newenviron I want to define some environments, which place their content into multiple different other environments. To access the contents I used the ...
12
votes
2answers
186 views

LaTeX adds an additional blank paragraph after the end of my custom environment

A friend, who is a LaTeX user but isn't very confident with customising it, told me that he would like to be able to put framed paragraphs and framed equations into his documents. So I took it upon ...
12
votes
3answers
8k views

Curly brace behind equations

I have the following question: I like to have a big curly brace behind the equations to show that they belong together and have only one equation number. An example without the brace would be ...
12
votes
2answers
1k views

Environments with conditionals in: why doesn't this work?

In response to this question I thought the obvious thing to do was the following: \documentclass{article} \newif\iffoo \newenvironment{foobar}{\iffoo}{\fi} \begin{document} \begin{foobar} Here is ...
12
votes
2answers
2k views

Difference between \begin{theorem}…\end{theorem} and {\theorem …}

I see that both attempts to display a theorem in the following code generates similar output. \documentclass{article} \usepackage{amsthm} \newtheorem{theorem}{Theorem} \begin{document} ...
12
votes
2answers
634 views

How to set preferred PDF viewer for texdoc in TeXLive 2010 pretest.

I had evince, installed TexLive 2010 pretest (ubuntu lucid linx, fresh install). texdoc was using evince. Then I installed kubuntu ontop, and texdoc switched to okular. Now I've installed acroread and ...
12
votes
1answer
84 views

Replicating an environment to another and making changes to original

I would like to define a new environment with the name oldproof which is basically the proof environment and then make changes to the proof environment. I would still like to be able to access the ...
12
votes
1answer
212 views

“Tape” environment in LaTeX

I have never defined an entirely new environment in a LaTeX document - I have only ever modified existing environments to suit my purposes. Now, however, I suddenly have a use for an obscure ...
12
votes
3answers
5k 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 ...
12
votes
1answer
716 views

Creating a new environment with referencing

I'm trying to create a referenceable "system" environment that basically displays an equation with a custom counter. Then I want to reference the environment with autoref, so as to have "System (S1)" ...
11
votes
4answers
405 views

Is there a ready solution to typeset a diff file?

In a text about Git I want to typeset diffs similar to this visualization: Commit details on GitHub. Is there any ready-made solution to that, especially the coloring of the diff lines? (In other ...
11
votes
2answers
1k views

A new environment based on enumerate

I have defined the following simple environment: \newenvironment{renumerate}{\begin{enumerate}\raggedright}{\end{enumerate}} I wonder how the above can be modified to use with, say, the following: ...
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?
11
votes
2answers
152 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 ...
11
votes
2answers
181 views

How to define an environment that begins with a node?

Please see the following definition: \tikzstyle{boxStyle} = [draw=blue!80, fill=blue!9, very thick, rectangle, rounded corners=3mm, inner sep=10pt, inner ysep=15pt] ...
11
votes
2answers
292 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
1answer
231 views

How does LaTeX implement environments?

Do you know how LaTeX implements environments? To be more precise, what does \newenvironment{<env-name>}[<n-args>][<default>]{<begin-code>}{<end-code>} in terms of TeX ...
11
votes
3answers
315 views

How to \enddocument inside an environment

I have a document of the form \begin{document} some text \begin{myenv} .... \end{myenv} some other stuff \end\document I would like to set a boolean \newif\if@test in the header to control the ...
11
votes
2answers
622 views

How can I check if the current code is inside a certain environment?

I would like to define a command which checks if it is executed inside a certain environment. Like this: \documentclass{article} \newenvironment{myenv}[0]{at start}{ at end} ...
11
votes
1answer
3k views

Avoiding “\Url Error ->\url used in a moving argument.” in a custom environment

I have a document I'm trying to render using two classes -- my university's dissertation .cls, and tufte-latex (my uni's styleguide is ugly, and I want to make a pretty-print version for my own ...