New answers tagged

2

Use the wide option supplied by enumitem: \documentclass{article} \usepackage{showframe,lipsum}% Just for this example \usepackage{enumitem} \begin{document} \sloppy% Just for this example \lipsum*[1] \begin{enumerate}[wide] \item Lorem ipsum\ldots \item \lipsum*[2] \end{enumerate} \lipsum*[3] \end{document}


0

We can realize it with \newenvironment and \comment from verbatim: \documentclass{letter} \usepackage{verbatim} \newif\ifshow \newif\ifhide \hidefalse \newenvironment{foo}[3]{ \ifshow #1\\ \else \def\a{#1} \def\b{#2} \def\c{#3} \hidetrue \expandafter\comment \fi } { \ifshow ----------- \else \expandafter\endcomment \...


2

Load the newfloat package and the scheme module for chemmacros. You just have to set up a subscheme environment for subcaption, which has to be done at begin document. I loaded tocbibind for adding \listoffigures and \listoftables to the table of contents. Your manual method is incorrect: you should at least have \cleardoublepage before \addcontentsline. \...


3

Here is how you can combine chemmacros' scheme module with subcaption and cleveref. I also changed the reference style to match the subfigures. Unfortunately \listofschemes currently seems to be incompatible with the book class (See also: corresponding bug report). I therefore used report for the following MWE: List of Schemes: References to schemes and ...


2

As @leandriis noted in the comments, the chemmacros package apparently already does what you want. Otherwise, you just have to add the lines \usepackage{newfloat} \DeclareFloatingEnvironment[fileext=los,placement={!ht},name=Scheme]{myscheme} \captionsetup[myscheme]{labelfont=bf} \crefname{myscheme}{scheme}{schemes} to your preamble and then can use a new ...


0

Here is a solution with a much easier definition of environments. It requires you to use but one more package, caption, in addition to listings and minted. \documentclass[12pt]{article} \usepackage{listings} \usepackage{caption} \usepackage[newfloat]{minted} \newminted{python}{ fontsize=\scriptsize, numbersep=8pt, frame=lines, framesep=3mm } ...


0

Based on David's answer. Here's my attempt to make things work for nested environments. \documentclass{article} \usepackage{amsmath, etoolbox} \def\hide#1{} % or \def\hide#1{#1} to not hide it. % Essentially flips "\begin{hidden}#1\end{hidden}" to "\begin{hidden}\end{hidden} \hide{#1}" \def\hidden{{\ifnum0=`}\fi\xhidden\argend}% \def\...


2

You actually want to add a group so that when you skip over & you do not end the alignment cell and so end the group where you started hiding. This version does not cope with nested environments, but works here and shows teh basic scheme. \documentclass{article} \usepackage{amsmath, environ} \def\hidden{{\ifnum0=`}\fi \xhidden} \def\xhidden#1\end#2{\...


0

If you're willing to adjust the input slightly - using \problem and \subproblem as commands rather than a command/environment approach, you can terminate the list after every \subproblem and use the enumitem-provided resume key to resume your sub-problem lists. \documentclass{article} \usepackage{environ} \usepackage{enumitem} \usepackage{xcolor} \...


1

Here's how you can shuffle the answers in a repeatable way, by fixing the seed. Devise a formula based on the student number to be fed as the seed. \documentclass{article} %\usepackage{xparse} % not needed with LaTeX 2020-10-01 or later \usepackage{enumitem} % much more powerful than enumerate \usepackage[dvipsnames]{xcolor} \usepackage{tikz} \newcommand*\...


2

You may be overthinking things with the myquotenumber code. Since the facts are supposed to use the same counter as equation, I think you might as well place the facts in \parbox statements. \documentclass{article} \newcommand\myparbox[1]{\parbox{0.667\textwidth}{\raggedright #1}} % choose width suitably \begin{document} This allows us to use the well ...


3

Beware adding unwanted space tokens. \newenvironment{myenv} {\noindent \begin{minipage}{.5\textwidth}% } {% \end{minipage}% \begin{minipage}[t][][b]{.5\textwidth} \vfill ! \end{minipage}% } works without having an underfull white line.


2

Instead of nesting an enumerate environment inside a myenv environment, you could define a new list environment with enumitem, where the black triangles would be placed automatically at the beginning and at the end. \documentclass{article} \usepackage{amssymb} \newenvironment{myenv}{$\blacktriangleright$}{\hfill$\blacktriangleleft$} \usepackage{enumitem} \...


0

It appears as though environments defined with \includecomment and \excludecomment are sensitive to whitespace. After removing the indentation from the SOLUTIONS environment, the file compiles without any errors. Here is the full file: \documentclass{article} \usepackage{comment} \usepackage{amsmath} \excludecomment{SOLUTIONS} %\includecomment{SOLUTIONS} \...


0

Two methods -- with the makebox and minipage with tabular environment and caption -- with the tabular and captionof environment since multicols does not accept normal caption with inputs from -- How to put captions below tables residing in multiple columns and tables side-by-side using minipage \documentclass[]{article} \usepackage{multicol} \usepackage{...


1

This seems to work: \documentclass{article} \usepackage{fancyvrb} \newenvironment{test}[1] {\VerbatimEnvironment\VerbatimOut[codes={\catcode`\^^I=9}]{#1}} {\endVerbatimOut} \begin{document} \begin{test}{\jobname.test} This line has no tab This line has one tab This line has two tabs This line has no tab \end{test} \VerbatimInput{\jobname....


0

Based on the solution by @gernot, with the fix I mentioned in the comments, which does not break align after first use of details, \documentclass{article} \usepackage{amsmath, xcolor, comment} \makeatletter \specialcomment{details}{% \xdef\@oldeverymath{\the\everymath}% \xdef\@oldeverydisplay{\the\everydisplay}% \global\everymath\expandafter{\@...


2

LaTeX has the macro \@ifnextchar. The name might be a bit misleading, you can not only use it to test the next single char, but also for a macro with a defined meaning, e.g., you can test whether the next thing in the input stream is \begin. This can be used to build a macro \ifnextenv. It will take three arguments, the name of the environment, code which ...


2

Here is a way to do it with a token-cycle. Every time I find a \begin{itemize}, I pre-execute \PREitemize, which here I set to \par Hi Mom, I am about to itemize. If there is a \begin detected but it is not itemize, I pre-execute \PREbegin, here set to \par Sorry, this begin is not itemize. \documentclass{article} \usepackage{tokcycle} \def\ITM{itemize} \...


1

If you are willing to start every tabular-environment's body with \setdelim{init}{init}, then you can crank out the case of the concatenation of \setdelim's first and second argument yielding the sequence initinit and do with only one flag. \documentclass{article} \usepackage{etoolbox} \makeatletter \newcommand\CheckWhetherinitinit[1]{% \ifcat$\...


2

The problem is that your boolean states won't be saved across columns and rows as each cell forms a group. Prefixing the \booltrue and \boolfalse calls with \global should solve this issue. Keep in mind that you'll have to reset the booleans to false for a new array. \documentclass{article} \usepackage{etoolbox} % Define command for automatic setting of ...


0

The problem is that you use \ExplSyntaxOn too late. It has to be activated at the moment when \NewDocumentEnvironment is read, because at this moment it is decided how e.g. _ will be processed. So you need something like \ExplSyntaxOn \NewDocumentEnvironment{myenv}{o}{... no switching of \ExpSyntax ...} \ExplSyntaxOff But now also tikzpicture, in particular ...


2

You need to branch on whether the optional argument is given or not. \documentclass{article} \usepackage{framed} \newtheorem{innertheorem}{Theorem} \newenvironment{theorem}[1][] {\if\relax\detokenize{#1}\relax \begin{innertheorem}% \else \begin{innertheorem}[#1]% \fi \mbox{}\par\nobreak \vspace{-\baselineskip}\vspace{3pt}% \begin{leftbar}\...


1

Your patch works fine here: \documentclass{nature} \makeatletter \renewcommand{\NAT@figcaption}[2][]{\AtEndDocument{% \refstepcounter{figure} \ifthenelse{\value{figure}=1}{ \newpage\noindent% % \rule{\textwidth}{1pt} }{ \par\vfill } \sffamily\noindent\textbf{Supplementary Figure \arabic{figure}}\hspace{1em}#2} }...


1

I think what you are searching for is probably \pretocmd from etoolbox package. Also, your LaTeX coding and indentation are a bit sloppy. If you may find it helpful, I have written a tutorial on LaTeX3. \documentclass{article} \usepackage{tagpdf} \usepackage{etoolbox} \tagpdfsetup{tabsorder=structure, uncompress, activate-all, add-new-tag=Title/P, ...


2

If you define the special comment details like that, then it works: \specialcomment{details}{% \global\everymath{\color{gray}}% \global\everydisplay{\color{gray}}% \color{gray}% }{% \global\everymath{\normalcolor}% \global\everydisplay{\normalcolor}% \normalcolor } The problem is that any definitions within an aligned cell are local, ...


0

Okay, I was a bit stupid. It was pretty easy. Here is the solution. Thank you guys in the comments for the ideas! \newenvironment{mainbox}[1][]{ \thmbox[M]{\ifblank{#1}{$\ $\hspace{33.75pt}$\ $}{\textbf{#1}}} \hspace*{-1.9em}\slshape\ignorespaces \normalfont } { \endthmbox\vspace*{.75ex} }


2

Here are two options: You can use the comment package and do \excludecomment{todo}, but this will insert a line break between the text before and after the environment: You can use xparse and redefine the environment to grab its contents with +b and throw them away, then you have no line break: Also, adding \ignorespacesafterend will avoid one spurious ...


1

Considering the commands you have already defined, I think that using an enumerate environment is not the easiest way to make the numbering automatic. Instead, you could define a new counter, and increment it at each new call of \tabform to number the corresponding row. Here's an example I built from yours. I added a new tabcount counter which is reset at ...


2

Don't try to use itemize. Instead, what you want to do is create your own counter. We'll assume that you're not going to have nested tabforms environments (if that's not the case, that will be a bit more involved. You'll need to create a new counter for your \tabform command, let's call it tabform: \newcounter{tabform} Next we want to be able to use it in ...


1

It's not entirely clear the intention here but the error is because you were calling \orig@tabular in the middle of the definition so its argument is the following token (\let) not the {cc} from the document. In this case all the following tokens are redefinitions of internal commands from tabbing not relevant to tabular so I simply deleted them, it runs but ...


2

First: align*, which you use to measure, is defined with \newenvironment{align*}{% \start@align\@ne\st@rredtrue\m@ne }{% \endalign } but you redefined \endalign to do nothing in your new environment, so you only have half the code for align* there. You need to redefine \endalign* to expand to \endoldalign: \cs_set:cpn { endalign* }{ \endoldalign } ...


5

You should not use \enumerate and \endenumerate, but the proper \begin{enumerate} and \end{enumerate}, but this would conflict with tabularx. Solution: if you don't plan to have \verb material in the items, you can use the b argument specifier. \documentclass{article} \usepackage{tabularx,booktabs,enumitem} \NewDocumentEnvironment{ucbx}{+m+m+m+m+m +b}{% \...


2

There are some errors in your code. First, aligned is an "internal" form which must be used within math mode; second, you cannot leave empty lines in math mode. TeX tries to recover, and the result is the strange mixture of text and math fonts you show. Your code issues dozens of errors: never ignore them. After correcting these errors, in order to ...


0

Cleveref adapts the label command to include an optional extra argument which describes which name to give the object. So one simply needs to replace \label{baz} with \label[theorem]{baz} and \label{baz2} with \label[theorem]{baz2}.


3

Add a \setlist to the code key-value: \documentclass{article} \usepackage[most]{tcolorbox} \usepackage{enumitem} \usepackage{xcolor} \definecolor{myColor}{rgb}{0.68, 0.05, 0.0} \newtcolorbox[auto counter]{exmp}[3][]{ breakable, enhanced, borderline west={2pt}{0pt}{myColor}, sharp corners, boxrule=0pt, fonttitle={\large\bfseries}, ...


0

As have answered here: my answer to another question, it can be done as follows: % \protectbox<optional, space ajust>{optional, height}{content} \newlength{\protectboxskip} \NewDocumentCommand\protectbox{D<>{0}om} { \IfNoValueTF{#2}% {% Height not given % measure the height \setbox0=\vbox{% \abovedisplayshortskip=0pt% \...


0

Well, I can answer my own question now. Recall that the meaning of this question is to achieve the following notepaper effect: Here's how it works. First, define a \protectbox to calculate the height of content (or manually given the height) and make it into a integer multiple of \baselineskip, so that the text follows stay right on the line. % \protectbox&...


Top 50 recent answers are included