Tag Info

New answers tagged

8

Using expl3 it's really simple: \documentclass[addpoints]{exam} \usepackage{expl3} \ExplSyntaxOn \cs_new_eq:NN \calc \fp_eval:n \ExplSyntaxOff \begin{document} \begin{questions} \titledquestion{First Question}[5] \titledquestion{Second Question}[5] \titledquestion{Third Question}[2] \titledquestion{Fourth Question}[2] \end{questions} ...


5

A quicker workaround, regardless which package is loaded first, is to use \numexpr from e-tex extensions (which should be available for basically any TeX distribution nowadays). It expands the values of the calculation before it's advance by \addtocounter In the following MWE the result is, as expected, 100 \documentclass{article} \newcounter{test} ...


5

Since calc redefines \setcounter, \stepcounter and \addtocounter, the only way you have if you want to keep your settings is to redeclare these definitions after loading amsmath. That is, add the following lines in your preamble after \usepackage{amsmath} \makeatletter \def\setcounter#1#2{\@ifundefined{c@#1}{\@nocounterr{#1}}% ...


0

I worked from @Bernards answer. However, as noted one has to guess the right value for multirow and vertical alignment in multirow is difficult. (ALl answers I found are along the lines do not use multirow and work around this way. rant Seems like high time for a better multirow implementation. However, I do not know the mechanisms in table, so I am not ...


3

The following should answer the question: \documentclass{article} \newlength{\mylenA} \newlength{\mylenB} \begin{document} \mylenA=5pt plus 2pt \showthe\mylenA % \mylenA = 5pt plus 2pt \setlength{\mylenB}{\mylenA} \showthe\mylenB % \mylenB = 5pt plus 2pt \setlength{\mylenB}{\dimexpr\mylenA} \showthe\mylenB % \mylenB = 5pt (no glue) ...


1

The makecell package has all the tools required for that. It allows for line breaks in cells, a common formatting of column heads, and multiline rotated heads. Here are threevariants of what can be done very simply: \documentclass{report} \usepackage{booktabs} \usepackage{graphicx} \usepackage{rotating, multirow} \usepackage{makecell} ...


1

I hope this will help you, just try this \settototalheight{\myl}{\hbox{% \begin{tabular}{cccc} \\ Sample & & \multicolumn{2}{c}{Group} \\ \rot{a} & & A & B \\ \end{tabular}}} \the\myl \settototalheight{\myl}{\hbox{% \begin{tabular}{cccc} Sample & & \multicolumn{2}{c}{Group} \\ \rot{a} & & A & B \\ \end{tabular}}} ...


3

One of your \xs is 0. TeX cannot divide by 0 so this is never going to work. Try substituting e.g. \x in -1/x with 0 to give -1/0 and it will not work even imperfectly! If you substitute 0.1 for 0, it does work perfectly: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{calc} \begin{document} \begin{tikzpicture} \foreach \x/\y in ...


1

This is possible with the datetime2 package \documentclass[italian]{article} \usepackage[calc,useregional]{datetime2} \newcount\myct \newcount\datecount \newcommand{\myday}[1]{% \DTMsavenow{mydate} \DTMsaveddateoffsettojulianday{mydate}{#1}{\myct} \DTMsavejulianday{mydate}{\number\myct} \DTMusedate{mydate} } \begin{document} \today~ is the ...


5

I suggest you a more powerful approach, where computations can be directly input. The interface3.pdf manual of expl3 will tell you the syntax for the “dimension expressions” in the arguments to \xifdimless and the “floating point expressions” in the argument to \eval. \documentclass[]{article} \usepackage{xparse} \ExplSyntaxOn ...


3

Store the result rather than the calculation: specified higher 1 divided smaller \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{etoolbox} \begin{document} % This comparison works well: small versus specified \newlength{\SmallLength} \setlength{\SmallLength}{1.2 pt} \newlength{\SpecifiedLength} ...


7

TeX has limited arithmetic capabilities; in this simple case you can say \renewcommand{\theequation}{% \the\numexpr 2*\value{SomeCounter}+1\relax.\arabic{equation}% } More complex functions could be used, with more complex methods.


4

I'm adding a snippet created in LuaTeX and a preview of the result. % lualatex mal-cells.tex \documentclass[a4paper]{article} \pagestyle{empty} \usepackage{luacode} \begin{document} \begin{luacode*} function malcompute() -- the core of computations counter=0 -- number of columns series={} -- actual values will be stored here seriesdata=tex.toks[1] -- get ...



Top 50 recent answers are included