Tag Info

Hot answers tagged

8

Package environ allows the capture of the environment body in a macro: \documentclass{article} \usepackage{environ} \NewEnviron{upc}{\MakeUppercase{\BODY}} \begin{document} \begin{upc} \noindent 23 Harrogate Dr. Foo, PA 17036 \\ 717.576.--- \quad Me@foo.com \end{upc} \end{document} A centered version. After \centering, the macro \\ is no ...


7

The orphane titles can be prevented using box like environments, which allow more design as well and automated counting (something like theorems, as Sigur proposed) I applied one of my favourite packages -- tcolorbox (No, I am not the author of that package, unfortunately :-() The colours, frames can be changed at will, as optional argument to the ...


7

You were almost there. You have to pass to \restatable the full expansion of recommendation\Alph{recommend@cnt} and then append the right tokens to \recommend@tions. \documentclass[a4paper]{article} \usepackage{thmtools} \usepackage{thm-restate} \usepackage{etoolbox} \makeatletter \def\recommend@tions{} \newcounter{recommend@cnt} ...


5

As egreg noted in the comments: The \addvspace macro must be issued in vertical mode! There is no conflict between \NewDocumentCommand and enumerate etc or enumitem. The solution to the error is that \addvspace must follow an explicit \par. The error would occur for \newenvironment too (see the probtrad environment. I suggest to use ...


5

It's possible using xparse and environ; the text is absorbed and the strings are converted to the accented forms and then delivered. \documentclass{article} \usepackage{xparse,environ} \ExplSyntaxOn \NewDocumentCommand{\textesperanto}{m} { \lokathor_convert_esperanto:n { #1 } } \NewEnviron{esperanto} { \lokathor_convert_esperanto:V \BODY } ...


4

A suggestion, to keep track of options and arguments, is to replace the iteration environment by a command, having some optional arguments etc. The typesetting will be done within of a tcolorbox box environment. The counter is incremented automatically and reset with each section. Please note, that the label must be used in the first optional argument as ...


4

I think that this is an expansion problem because you are trying to create a dynamic label for your restartable recommendations that depends on a counter. TeX does not seem to like expanding in such places unless forced! It is a little ungainly but I get around this using \fakerec in the macros below. Here is the output: and here is the code: ...


3

Not precisely what the O.P. wants to have (not twocolumn mode and automatically), but parallel with parallel package: \documentclass{article} \usepackage{parallel} \usepackage{mathtools} \usepackage{amsthm} \newtheorem{definition}{Definition} \newtheorem{example}{Example} \begin{document} \begin{Parallel}{0.4\textwidth}{0.4\textwidth} \ParallelLText{% ...


3

I assume you're talking about proof as defined by amsthm. The command \itshape is hardwired in the environment's definition. I suggest patching it so it uses a “generic” command that you can redefine at will: \usepackage{amsthm} \usepackage{xpatch} \xpatchcmd{\proof}{\itshape}{\normalfont\proofnameformat}{}{} \newcommand{\proofnameformat}{} % add nothing ...


3

Simply add numberwithin=chapter to the definition: \documentclass[12pt]{book} \usepackage[english]{babel} \usepackage[margin=2cm]{geometry}% just for the example \usepackage{xcolor} \usepackage{amsthm} \usepackage{thmtools} \usepackage{mdframed} \usepackage{etoolbox} \declaretheoremstyle[ spaceabove=6pt, spacebelow=6pt, ...


3

You can redefine the way Verbatim works using \RecustomVerbatimEnvironment, adding the formatcom key to execute formatting commands at the start of the Verbatim environment. Since the environment scope limits the extent of what happens with the content of formatcom, there is no need to reset it at the end: \documentclass{article} ...


2

Your approach here is to avoid having \WhatDoYouWantToWrite{All} throughout the document and then having to change every All to PartA (or something else) at a later stage. It's better to not pass an argument at all, and set something at the global level. Here is one such approach using TeX \if-statements: \documentclass{article} \newif\ifALL% ...


2

Here is a flexible solution using pgfkeys that allows for arbitrary switches that are given as keys to the command/environment. I define two (user) commands \SelectCommentsToPrint and \SelectiveComment. The first command controls which comments will be printed and the second command defines the comments and specifies under what conditions they should be ...


2

Not sure if this is what you want: \documentclass{article} \usepackage[english]{babel} \usepackage[margin=2cm]{geometry}% just for the example \usepackage{xcolor} \usepackage{amsthm} \usepackage{thmtools} \usepackage{mdframed} \usepackage{etoolbox} \makeatletter \patchcmd\thmt@mklistcmd {\thmt@thmname} {\check@optarg{\thmt@thmname}} {}{} ...


2

Redefining the environment mycenter which was causing some trouble, with: \newenvironment{mycenter}% {\parskip=0pt\par\addvspace{\mylength}\centering}% {\par\addvspace{\mylength}\noindent\ignorespacesafterend}% Redefining the custom environment defi using tikz as for the theo environment, so that I could understand what the code, Changing \mylength to an ...


2

This might be an approximation to your wish; however, I find the numbering scheme too fussy: I see no reason for statements to be numbered under notes. If \newnote is immediately followed by \begin, a theorem-like statement is assumed. \documentclass{article} \usepackage{amsthm} \usepackage{thmtools} \usepackage{chngcntr} \usepackage{lipsum} ...


2

Something like this? \documentclass[12pt]{article} \usepackage{mathtools,amsthm} \newtheoremstyle{case}{}{}{}{}{}{:}{ }{} \theoremstyle{case} \newtheorem{case}{Case} \begin{document} \begin{proof} \begin{case} something \end{case} \begin{case} case \end{case} \end{proof} \end{document}


2

The easiest way is to use \lstnewenvironment with an optional argument, which sets the \lstset options in the environment startup code. This definitely easier than to struggle with the special problem that the listings environment switches to verbatim and the necessity to inject a string \end{lstlisting} rather than the token \end{lstlisting} ...


2

The minted package just offers the \newminted facility, which has several limitations. You can profit of the powerful tcolorbox package, instead: \documentclass{article} \usepackage[most]{tcolorbox} \tcbuselibrary{minted} \NewTCBListing{codeblock}{O{python}}{% %colback=white,colframe=white, listing only, minted language=#1, } \begin{document} ...


2

This is somewhat of an old question but I was interested in how to put a line down the margin, where the side changes depending on the parity of the page number. Rather than using the mdfamed package I have used tcolorbox as I am more used to using it. For answer this question, tcolorbox has one particularly useful switch, toggle left and right, that can ...


2

An "as-it-is environment" is environment is given by verbatim: \begin{verbatim} REMARK ATOM 1 O25 KKM 1 41.799 30.649 -26.049 ATOM 2 C25 KKM 1 41.727 29.258 -25.898 ATOM 3 C24 KKM 1 42.793 28.745 -24.865 ATOM 4 C23 KKM 1 44.141 29.190 -25.292 ATOM 5 C22 KKM 1 44.161 ...


2

To have the appropriate baseline skip, you need to end the paragraph: \BeforeBeginEnvironment{quotation}{\par\begin{singlespace*}} The complete example: \documentclass{article} \usepackage{setspace} \doublespacing \usepackage{etoolbox} \BeforeBeginEnvironment{quotation}{\par\begin{singlespace*}} \AfterEndEnvironment{quotation}{\end{singlespace*}\par} ...


1

You can obtained the same result with the empheq package (needless to load amsmath in that case): \documentclass[12pt]{article} \usepackage{empheq} \usepackage{xcolor} % Colors \usepackage{soul} % Highlighting and strikeout \newcommand{\MA}[1]{{\sethlcolor{cyan}\hl{#1}}} %highlighting \newcommand*\hlbox[1]{% \colorbox{cyan!30!}{\quad#1\quad}} ...


1

A solution based on ntheorem, mathtools and etoolbox: \documentclass[twoside,a4paper,11pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \usepackage{amsfonts} \usepackage[hmargin=3cm]{geometry} \setlength\parindent{1.1cm} \usepackage{microtype} \usepackage{mathtools, amssymb} \newtagform{bold}{\bfseries(}{)} ...


1

This works, but would I use it (this way)? No. For more sophisticated setups, the environment must be used with arguments, preferably with \NewDocumentEnvironment from xparse \documentclass{book} \newenvironment{example}{% \begin{tabular}{ll} }{% \end{tabular} } \begin{document} \begin{example} A & B \end{example} \end{document}


1

Only preliminary solution... indentation not done yet. \newtheorem{foo}{Foo}[section] will define an environment named foo, titled Foo and a counter named (you guess it -- foo ;-)), which is reset each time the section counter is stepped. \newtheorem{otherfoo}[foo]{Otherfoo} will define an environment named otherfoo, titled Otherfoo and no counter -- it ...


1

Don't do this at home ;-) The trick is to fake the current environment to be multicols right at the start of abstract, then stopping the multicols environment, setting the abstract environment correctly and using \AfterEndDocument from etoolbox package to resume the \begin{multicols}{2}. \documentclass{article} \usepackage[utf8]{inputenc} ...



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