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

64
votes
3answers
28k 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?
44
votes
7answers
2k views

Why can't the end code of an environment contain an argument?

Environments are allowed to have arguments, but reference to those arguments can only appear in the opening code of the environment, and not the closing code. What is the reason for this, and are ...
43
votes
1answer
2k views

Defining environments based on other ones: What's the right way?

Assume that I want to define a new environment that is a variant of an existing one. For example, I seek an italicquote environment that acts like the quote environment but displays its contents in ...
42
votes
9answers
2k views

Where do I find out how a command/environment is defined?

Say I want to redefine the itemize environment, or make a modified version of it. I want to know how it is currently defined. Where do I find this information? If it's some particular package command, ...
41
votes
3answers
11k views

Is it a bad idea to use \begin{section} … \end{section} in LaTeX?

In several discussions about relatives merits of LaTeX v. xml, a xml supporter complained that in LaTeX sections, subsections etc are not properly closed, so it is hard to tell where a section ends. ...
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 ...
26
votes
1answer
209 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 ...
25
votes
2answers
2k views

How to automatically add text immediately after \begin{document}

I attempted to redefine the document environment as follows, but get a complaint that: LaTeX Error: \begin{MYdocument} on input line 13 ended by \end{document}. \documentclass[12pt]{article} ...
25
votes
2answers
3k views

Label and caption without float

I’d like to have an environment that works much like a float, except that it doesn’t float. That is, in fact, I’d like to be able to define an environment that has a label and a caption. I ...
24
votes
4answers
1k views

Do all starred commands have anything in common?

\section* produces an unnumbered section, align* makes the environment unnumbered, which is comparable in a way. \newcommand* doesn't accept \par in its argument, which is different. Stefan Kottwitz ...
24
votes
2answers
567 views

Environment that counts words inside

How can I create the environment that could count words inside itself? More specifically, I want to write an enviroment called "assignment" such that the code \begin{assignment} Some words here. ...
24
votes
4answers
4k views

Numbers outside Math environment

Should numbers inside the text be placed inside a math environment? For example, if I am writing ...indent code by 4 spaces..., should I write it this way or ...indent code by $4$ spaces...? ...
23
votes
3answers
599 views

Does \newenvironment have a \provideenvironment cousin, as \newcommand has \providecommand?

To avoid the problem of having to decide whether to use \newcommand or \renewcommand, LaTeX has the option of \providecommand. Is there something corresponding to this for environments? I'd like to ...
23
votes
2answers
3k views

Definitive guide to trivlists

I create a lot of theorem-like environments, and I'm usually happy to employ a package (such as ntheorem, amsthm, etc) to do the work for me. After studying the ntheorem documentation, and reading ...
22
votes
2answers
2k views

Defining a new environment whose contents go in a TikZ node

I would like to define an environment which typesets the contents in a box, and I'd like to use TikZ (I'm aware of alternatives like fancybox). So I would like something like \newenvironment{abox}% ...
21
votes
3answers
459 views

Comma-separated list environment

This question is somewhat of a follow up to an answer to a previous question (http://tex.stackexchange.com/a/11587/13522). I would like to create a list environment (similar to itemize and enumerate) ...
21
votes
1answer
238 views

Environments for visually setting text apart

I have a document consisting of alternating paragraphs from different voices. Because the paragraph blocks look too much alike, I need some way to give the different parts a different look. I have ...
20
votes
2answers
5k views

How to modify spacing around quotation environment?

I am almost there in my quest to reproduce the rather compact layout of the book I'm translating... one thing to go, though: I successfully used the enumitem package to modify the vertical and ...
20
votes
2answers
8k views

What does the titlepage environment do and what are its benefits?

I'm speaking about the article document class only, because report and book deal with titles in a different way. Obviously, the titlepage environment triggers a new page after it, and it resets the ...
20
votes
2answers
1k 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 ...
19
votes
7answers
831 views

How to create a command that automatically escapes curly braces?

How could I create a command that will automatically escape all curly braces within the current environment? For instance, I would like a command (or environment, I suppose) that allows me to write ...
19
votes
5answers
574 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 ...
19
votes
3answers
7k views

Quote environment with reference at the end right

I want to define a quote environment such that after the quote on the right occurs the author with page number. My solution is yet the redefinition of the quote environment \usepackage{amsthm} % ...
19
votes
4answers
6k views

Making a new environment combining equation and split

I'm trying to define a new environment that consists of a split environment inside an equation environment. But I'm getting an error. Here's what I'm doing: \documentclass[a4paper,12pt]{article} ...
19
votes
4answers
774 views

Is there a reason to use \begin{environment} \end{environment} rather than \environment \endenvironment?

What reason (other than perhaps being easier for my syntax highlighter to parse) is there to write \begin{center} Here is centered text \end{center} rather than: \center Here is centered text ...
19
votes
2answers
339 views

I want to start learning how to use \newcommand \newenvironment and \def any suggestions where to start?

I have been using LaTeX for a long time now, and I find myself often going to this website to solve my problems. This often includes copy pasting codes which include \newcommand, \newenvironment and ...
18
votes
5answers
3k views

New figure environment

I am writing my PhD thesis. In my manuscript I have Figures in the text and Photographic plates (a figure of figures) in the annexes. The two elements are different and I would like create a new ...
18
votes
4answers
2k views

How to prevent paragraph breaks after theorem environments?

By default, the list environments (such as itemize) have the nice property that if you add a blank line after it, it starts a new paragraph, and if you don't, the paragraph continues. So The ...
18
votes
1answer
2k views

Passing \newenvironment parameters to the end block?

I am attempting to construct a new environment which will allow me to format arbitrary list types (itemize, enumerate, description etc.) with the new environment. As such I am passing it as a ...
18
votes
1answer
181 views

Is it bad style to have spaces in environment names?

I've recently realized that, due to how \newenvironment, \begin, and \end work, there is no reason you can't have environment names with spaces in them. As long as you stick with \begin and \end, this ...
17
votes
1answer
544 views

How to typeset programming code syntax with annotations?

If possible I would like to know how to this on latex/tikz to add this like (environment and graph) on my ebook. Thanks a lot!!! Code im trying to implement: \documentclass[11pt,fleqn]{book} ...
17
votes
2answers
349 views

Why do I have to put the center environment in a group for \@afterindentfalse\@afterheading to suppress indentation?

Consider the following two macros, the only difference being that one has the environment inside a group: \documentclass{article} \makeatletter \newcommand\thisworks{% {\begin{center} $\ast$ ...
17
votes
2answers
8k views

Block comments with *% and %*

I know the package comment which allows to use : \begin{comment} Lines to comment \end{comment} This is not very friendly to use. I would like to have the following possibility: *% Lines to ...
17
votes
2answers
601 views

Graph of dependencies from LaTeX file

This is inspired by the MO question here. Suppose I'm writing a math paper, with theorem and proofs, etc. At the end of writing, I want to design a graph of dependencies, that is, a graph containing ...
16
votes
6answers
499 views

A new environment to decide dynamically which commands to run?

I am having some user defined commands defined and used in my latex document. I need a way to check whether any of the commands is used. I want to make decisions based on the argument used in the ...
16
votes
5answers
29k 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 ...
16
votes
3answers
1k views

Formatting FAQ lists in LaTeX

I want to format a list of "Question + Answer" pairs in a TeX-document. In HTML I use the <dl> command: http://www.w3.org/TR/html401/struct/lists.html, e.g.: <dl> ...
16
votes
5answers
8k views

Customizing theorem name

Suppose I have a series of theorems that I would like displayed as Jim's Theorem. Bob's Theorem. Will's Theorem. rather than as “Theorem (Jim).”, “Theorem (Bob).”, and “Theorem ...
16
votes
3answers
1k views

Why does LaTeX make a distinction between commands and environments?

Why does LaTeX make a distinction between commands and environments? Or also: why do we need environments? I ask this because I am defining a number of custom commands (like \question{} and ...
16
votes
2answers
867 views

A special example environment

How can I define an environment named "example" so that: can be broken over pages has a horizontal line above "Example \chap.\no" (e.g. Example 4.10), and vertical line that is spread to the whole ...
16
votes
2answers
21k 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?
16
votes
2answers
353 views

Duplicating Environments

When I want to globally modify a command in my document, I will often use a duplicated version of the original in the stencil, with the help of the \let macro. For example, if I wanted to do ...
16
votes
1answer
580 views

How to define a starred version of an environment in LaTeX

I am interested in defining a new environment in LaTeX that has a starred version. How is this done?
16
votes
1answer
323 views

What exactly does the \begin{document} command trigger?

Let us consider these two files first. \documentclass{article} \parindent 0.0mm \hyphenpenalty 500 \tolerance 700 \usepackage{lipsum} \begin{document} \lipsum[1-10] \end{document} ...
16
votes
1answer
493 views

What exactly does \@doendpe do?

Quoting from the LaTeX2e sources: [\@endparenv, \@doendpe] To suppress the paragraph indentation in text immediately following a paragraph-making environment, \everypar is changed to remove ...
16
votes
1answer
385 views

What is the difference between \newenvironment and \newenvironment*?

I vaguely seem to recall reading that \newenvironment* gives better spacing than \newenvironment, but I don't recall any details and I can't seem to find a reference by searching. What is the ...
15
votes
5answers
803 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
3answers
2k 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
5answers
798 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 ...
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 ...