Hot answers tagged

9

You can easily adapt the definition of \alph which is defined like this in latex.ltx: \def\alph#1{\expandafter\@alph\csname c@#1\endcsname} \def\@alph#1{% \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else\@ctrerr\fi} So here is a MWE for a custom ...


5

the main culprits are the incorrect use of % after the 1 which prevents the 1 being terminated, and the lack of a space after 0. In some cases you can terminate a number with \relax but that leaves a \relax in the token stream which is not always desirable, a space is absorbed as part of the number. \newcount\animalnum \def\nextanimal{% \ifcase\animalnum ...


4

Use \ifnum instead of \ifx. \documentclass{article} \newcounter{counterA} \newcounter{counterB} \setcounter{counterA}{2} \setcounter{counterB}{2} \newcommand\maccommand{% \ifnum\the\value{counterA}=\the\value{counterB} Just so you know, counterA (= \the\value{counterA}) holds the same value as counterB (= \the\value{counterB}).% \else ...


4

Something like this? \documentclass{report} \newcounter{A} \newcounter{B} \setcounter{A}{1} \setcounter{B}{\value{A}} \newif\ifB \Bfalse \newcommand{\setA}[1]{\setcounter{A}{#1}\ifB\else\setcounter{B}{#1}\fi} \newcommand{\setB}[1]{\global\Btrue\setcounter{B}{#1}} \begin{document} \setB{5} A=\theA B=\theB \medskip \setA{3} A=\theA B=\theB ...


3

Here is an option: Let the representation of B print \theA until \setB is used. \documentclass{article} \newcounter{A} \newcounter{B} \setcounter{A}{1} \setcounter{B}{\value{A}} \renewcommand{\theB}{\theA} \newcommand{\setA}[1]{\setcounter{A}{#1}} \newcommand{\setB}[1]{\renewcommand{\theB}{\arabic{B}}\setcounter{B}{#1}} \begin{document} \setB{5} ...


3

You could write the number of pages to a file at the very end of the document. That way you can read it in during your pages load (if it exists) and set content accordingly: \documentclass{article} \usepackage{lipsum} \usepackage{atveryend} \usepackage{hyperref} \AtVeryEndDocument{% \newwrite\pagesfile% Create new write file ...


3

\counterwithin{equation}{part} does not remove the equation counter from the chapter reset list. It must be kicked out explicitly with \counterwithout{equation}{chapter}. The counter formatting \theequation should be changed afterwards then, since \counterwithout{equation}{chapter}. Or use \counterwithout*{equation}{chapter} Here's the (modified) MWE: ...


3

\thecounterA works only if the counter wasn't redefined: \documentclass{article} \newcounter{counterA}\renewcommand\thecounterA{A\arabic{counterA}} \newcounter{counterB}\renewcommand\thecounterB{B\arabic{counterB}} \setcounter{counterA}{2} \setcounter{counterB}{2} \newcommand\maccommand{% \ifnum\value{counterA}=\value{counterB} Just so you know, ...


3

I have had the same problem, and came up with the following solution. The enclosed LaTeX input takes a given PDF file (= one copy of the questionnaire) and creates N copies, each numbered 000..N. The number is added in light grey to the lower right corner. Feel free to customize as you like. % Print an exam N times, with serial numbers 000...N % by ...


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

You can certainly do, in plain TeX, \newcount\counterA \counterA=2 \ifx\counterA>2 Just so you know, counterA is greater to than 2. \else Just so you know, counterA is not greater than 2. \fi but this will compare the token \counterA with the token > and find they've different meanings, so everything up to \else will be gobbled and you'll ...


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

Calculations can be done with \numexpr number1 operator number2, but in this case, the example is a little bit useless, since the number of & is fixed to use 3 columns (in between) anyway! \documentclass{article} \newcounter{myCounter} \setcounter{myCounter}{3} \begin{document} \begin{tabular}{cl*{\value{myCounter}}{c}c} & ...


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

Instead of transparent you can also use TiKZ opacity. Following complete example shows how to use it supposing that every image will show a different opacity. \documentclass{beamer} %\usepackage{default} \usepackage{graphicx} \usetheme[hideothersubsections]{Goettingen} \definecolor{fondtitre}{rgb}{0.83,0.03,0.03} % dark red \setbeamertemplate{background ...


1

The LaTeX kernel has some non publicized programming tools, such as while loops. The more well-know \loop is not appropriate here inside the tabular for a number of reasons, one being that it makes a local definition which will get lost, the other one is that \cline also uses \loop and this would clash. Here is a one-liner to get user access to one LaTeX ...


1

This finally works: \documentclass{article} \usepackage{hyperref} \usepackage{lipsum} % this is the solution \usepackage{lastpage,refcount,totcount} \newtotcounter{totlastpage} \hypersetup{pdfprintpagerange=2 \the\totvalue{totlastpage}} \AtBeginDocument{ \setcounterpageref{totlastpage}{LastPage} \addtocounter{totlastpage}{-1} } \begin{document} ...



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