{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
5answers
893 views

Command behavior depending on current environment

I would like to write a LaTeX macro whose code depends on the parent environment such as: \newcommand\test{ %if current_environment=env1 test1 %elseif current_environment=env2 test2 %else } ...
15
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: ...
15
votes
3answers
3k views

Problem with redefining Tabular environment with the \renewenvironment ‎command‎

In a book I'm typesetting, I want the tabular environment to be in footnote size and the other body of the book to be in normalsize font. To do this, I've tried something like the following: ...
15
votes
2answers
2k views

How to create new table environment

I am working on a book that has many many such tables. Is there a way to create shortcut for the code shown below. I want to make table caption a variable, because in the MWE shown below except ...
15
votes
4answers
570 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 ...
15
votes
2answers
448 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
817 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
865 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
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: ...
14
votes
2answers
218 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
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] ...
14
votes
2answers
410 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
404 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
2answers
666 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 ...
14
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 ...
14
votes
1answer
364 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
483 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
209 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
303 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
1answer
722 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
4answers
360 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
2answers
934 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
2answers
176 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
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
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 ?
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
1answer
168 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
538 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
525 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
784 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
138 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
421 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
316 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
198 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
1answer
85 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
4answers
6k 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
218 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
1answer
843 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)" ...
12
votes
1answer
3k views

Adjusting space before and after a latex beamer block

I wanted to ask you if there is a better way to adjust the spacing between two beamer blocks: \documentclass[slidestop]{beamer} \usetheme{Madrid} \begin{document} \addtobeamertemplate{block ...
11
votes
4answers
437 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
301 views

Defining a new command name in the correct way

I'd like to define a short command name \gm{a,b} that would mean in LaTeX \overset{a\to b}\longrightarrow I tried on my own. The below code only works for \gm{a} (or \gm{b} if changing a into b) ...
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
161 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
186 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
316 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} ...