Hot answers tagged

9

(Admittedly, the example with \color) could be achieved without this, but let us assume \mycmd is more complex for the real case and not a toy 'theory';-)) Collecting the environment body is easiest with environ package and its \NewEnviron command and \BODY. \documentclass{article} \usepackage{xcolor} \usepackage{environ} \usepackage{blindtext} ...


8

In LaTeX, the \begin{foo} and \end{foo} actually call the commands \foo and \endfoo. So one way to achieve what you want is to simply redefine \quote: \documentclass{article} \usepackage[margin=1.8cm, a4paper]{geometry} \usepackage[parfill]{parskip} \usepackage{lipsum} \let\origquote=\quote \def\quote{\origquote\small} \begin{document} <what you ...


8

Taking a file, xyz.tex, I just used as an answer to another question \documentclass[12pt]{report} \usepackage{array} \usepackage{amsmath} \begin{document} \begin{tabular}{| >{$}c<{$} | c | c | c | c | c | c |c |} \cline{2-8} \multicolumn{1}{c|}{}&\multicolumn{7}{c|}{\rule{0mm}{0.4cm}{figure1 put here}}\\ \hline \rule[-.5cm]{0mm}{1.2cm} x & ...


8

Place \unskip after \egroup to make the two invocations behave the same. \documentclass{article} \newenvironment{nothing}{\setbox0\vbox\bgroup} {\egroup\unskip} \begin{document} Hello, this is some text. \begin{nothing} This is nothing. \end{nothing} More text. Hello, this is some text. More text. \end{document}


6

Although \( and \) are robust commands, it is safer to use $ in moving arguments like chapter and section titles. This seems to be a case in which these commands were insufficiently robust.


4

Just guessing from the error message as no example provided here %\RequirePackage[2014/01/01]{latexrelease} \documentclass{book} \begin{document} \tableofcontents \chapter{a \(x\) b} xxx \pagebreak xx \section{x} x \end{document} One of your systems is older than 2015 and so \( is fragile so must be used as \protect\( in headings. the other system is ...


4

Something like this? Catching the content of the environment with \BODY and applying the \footnotetext to this? \documentclass{memoir} \usepackage{xcolor} \usepackage{environ} \NewEnviron{mynote}{% \marginpar{\footnotemark}% marginal mark for the note \footnotetext{{\color{purple}\BODY}}}[\par] \begin{document} This experimental setup has evolved ...


4

You need \ignorespacesafterend; but you can consider the comment package. \documentclass{article} \usepackage{comment} \newenvironment{nothing} {\setbox0\vbox\bgroup} {\egroup\ignorespacesafterend} \begin{document} Hello, this is some text. \begin{nothing} This is nothing. \end{nothing} More text. Hello, this is some text. More text. Hello, this ...


4

You have some errors in your code: unmatched braces are the main one. Secondly, \hfill\\ is a don't-do-it; after \noindent you need \ignorespaces. And finally you have a load of unprotected end-of-lines, which may be irrelevant in this particular case, but it's good habit to have the correct % everywhere. \NeedsTeXFormat{LaTeX2e} ...


4

It would be better if you posted a full minimal working example as the answer might (but probably doesn't) depend on the package that you use for theorems etc. In any case, I think you need \renewcommand\thetheorem{\alph{theorem}}` With this you obtain: I am assuming that you only want to make the theorem counter alphabetic, and not the sections. Here ...


4

Here is a solution \documentclass[]{memoir} \newenvironment{dialogue}{% \newcommand\one{\normalfont\item[M:]}% \newcommand\two{\normalfont\item[P:]\itshape}% \newcommand\NormalText{\item[]\normalfont}% \list{}{\rightmargin2cm\leftmargin2cm\labelsep1cm} }{\endlist} \usepackage{lipsum} \begin{document} \lipsum[4]% \begin{dialogue}% \two ...


3

You can capture the contents of an environment using environ: \documentclass{article} \usepackage{environ,marginnote} \NewEnviron{myenv}{% % <some stuff here> \marginnote{\BODY}% % <other stuff here> } \begin{document} Here is some text. \begin{myenv} My Text Here. \end{myenv} Here is some more text. \end{document}


3

In LaTeX, \begin{foo} and \end{foo} actually call the commands \foo and \endfoo, so you can try modify them directly if the \newenviornment method doesn't work. With the particular case of the gather environment, I believe it changes the way certain characters are handled which I think is the cause of the issue. This can be solved by preventing \gather ...


2

Update If the envcountsame document class option is given, all llncs defined theorems use the theorem counter as shared counter. Now, envcountsame enables \newaliascnt, defining an alias counter, which in turn checks (for this question relevant) for \c@remark if it already exists. In order to decouple remark from theorem, \c@remark must be \relaxed and ...


2

Let's see what happens with a standard \endnote command: \documentclass{article} \usepackage{endnotes} \newcommand{\foo}{foo} % just for the test \begin{document} Some text.\endnote{With a \foo{} explanation.} \end{document} After processing this document, you'll find a file with extension .ent containing \@doanenote {1} macro:->With a \foo {} ...


2

The error occurs because of the way that the align environment processes the material in its scope: LaTeX is set to look ahead for the hard-coded string \end{align}, at which point processing of the material in the align environment begins in earnest. With your definitions of the SPalignX environments, after \begin{align} LaTeX will eventually come across ...


2

Does this qualify as simpler? ;-) \documentclass[]{memoir} \usepackage{lipsum} \providecommand{\one}{} \providecommand{\two}{} \providecommand{\NormalText}{} \newenvironment{dialogue} {% \renewcommand{\one}{\par\makebox[0pt][r]{\makebox[1cm][l]{\normalfont M :}}\normalfont}% \renewcommand{\two}{\par\makebox[0pt][r]{\makebox[1cm][l]{\normalfont P ...


2

You can make temporary redefitions at the beginning and end of environment with the help of hooks provided by the etoolbox package. So a first attempt is: \documentclass{article} \usepackage{mathtools,amsthm,etoolbox,cleveref} \newtheorem{theorem}{Theorem} \newcounter{equationstore} ...


2

Change \renewenvironment{leftbar}[1] to \renewenvironment{leftbar}[2] then replace blue by #2 and you can use \begin{leftbar}{red}


2

You can not use the arguments in the end code, but you can save the caption: start the begin code with \def\savedcaption{\caption{#1}}% then replace your existing \caption{#1} in the end code with \savedcaption


2

Something like this? \documentclass{article} \usepackage{enumitem} \newcounter{mycounter} \newif\ifinside \setlist[itemize,enumerate,1]{before*={\ifinside\relax\else\stepcounter{mycounter}\insidetrue\fi},after*={\insidefalse}} \begin{document} \begin{enumerate} \item one \item two \begin{enumerate} \item three \item four \begin{itemize} ...


1

It's the same problem as in Create environment inside another environment? The tabularx manual says that in order to use the environment in the definition of another one, you have to use the “internal” forms \tabularx and \endtabularx. The same is true for tabulary although the manual does not specify it. \newenvironment{schedule}[1] {\textsc{#1}\par ...


1

This sounds like a complete senseless requirement. Why using a number at all then? But if you want: \documentclass{llncs} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \renewcommand\theremark{1} \begin{document} \begin{remark} abc \end{remark} \begin{remark} abc \end{remark} \end{document}


1

You can't put a lstlisting environment directly in an lrbox, but you can in a \vbox (a lower level object). \documentclass{beamer} \usepackage{listings} \lstnewenvironment{code}[2][] {\lstset{#1}\global\setbox#2\vbox\bgroup} {\egroup} \newsavebox{\mybox} \begin{document} \begin{code}[basicstyle=\ttfamily]{\mybox} blahblahblah \end{code} \begin{frame} ...



Only top voted, non community-wiki answers of a minimum length are eligible