# Tag Info

7

You may load xintexpr for this, and allow LaTeX3 some rest. \documentclass[12pt]{article} \usepackage[hscale=0.75]{geometry} \usepackage{xintexpr} \usepackage{siunitx} \usepackage{shortvrb} \begin{document} $$\sum_{i=1}^{300} i^2=\num{\xinttheexpr add(i^2, i=1..300)\relax }$$ % For some reason, this doesn't go through: % \num{\xintthefloatexpr [14] ...

23

Yes, you can, and pretty easily too. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\computesum}{mmm} {% pass control to an internal function \svend_compute_sum:nnn { #1 } { #2 } { #3 } } % a variable for storing the partial sums \fp_new:N \l_svend_partial_sum_fp \cs_new_protected:Npn \svend_compute_sum:nnn #1 #2 #3 { ...

1

As nobody mentioned the use of let, I add this answer for the seek for completeness. \begin{tikzpicture} \matrix[column sep=1cm]{ \node (n1) {1}; & \node (n2) {2}; & \node (n3) {3}; & \node (n4) {4};\\ }; \foreach \a in {1,...,3} {%<-- Something like this (but don't use \x inside let!) \draw[red, -latex] let \n{a}={int(\a+1)} in ...

5

Like this? \documentclass{article} \usepackage{tikz,lipsum,showframe} \tikzset{mybox/.style = {text width=\dimexpr\linewidth-20pt-\pgflinewidth\relax,align=justify,draw=red, very thick, rectangle, rounded corners, inner sep=10pt, inner ysep=10pt}, fancytitle/.style ={fill=red, text=white,rounded corners} } \begin{document} \noindent ...

7

Another alternative from tikz-3dplot that provides more fun stuffs. Set the xyz coordinate system to xy coordinate system by \tdplotsetmaincoords{90}{90} Draw a large square first. Determine the vanishing point (X) at the center of the square. Use calc to determine the coordinates of a smaller box via ($(d\i)!\s!(X)$) that requires calc. Switch back to xyz ...

5

The red and blue lines are just to show the vanishing point -- they start from each coordinate of the rectangle, and converge at the vanishing point (X). A scope is used to translate the object to 70% of the way to the vanishing point, and scale the object to 30% of its original size. Notes: Package the application of the scope to apply a shift and ...

6

May be I misunderstood the question (happens to me lately), but may be you are looking for \usetikzlibrary{calc} .. \coordinate (vanishingpoint) at (10,3); \draw (1,0) -- ($(1,0)!2cm!(vanishingpoint)$);

2

How to divide with tikz calc (to find center of mass) seems to suggest that it isn't possible to divide with TikZ calc. Indeed, switching to multiplication does work. \newcommand{\MathPunctTwo}[5]{% \pgfmathsetmacro\radius{#4 * 0.8}% \node[dot,label={[label distance=-.1cm]-#5:{\tiny #2}}] (#2) at (-#5:\radius cm) {}; } ... But comment from @percusse ...

3

You can use the xintexpr package for expressions or its sub-component xint and xintfrac for using macros. These macros are expandable. Hence they can be used directly in length definitions or assignments to counters, etc..., naturally if the number does not exceed the TeX bounds. The macros by themselves deal with arbitrarily big integers or fractions or ...

1

Package xintexpr allows exact computations on arbitrarily big numbers and fractions and decimal numbers, and it allows definition of variables (with no \) for use in later \xintexpr, \xintfloatexpr or \xintiexpr. It works purely internally to TeX, building upon the e-TeX extension \numexpr. It can do floating point evaluations according to the value set by ...

5

Sure you can, if you use the right syntax (you need three dots in {0.1,0.2,...,1.0}): The code: \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{shapes,calc} \begin{document} \begin{tikzpicture} \node[draw,regular polygon, regular polygon sides=8,minimum width=5cm] (polygon) {}; \foreach \mypercent in {0.1,0.2,...,1.0} \node[draw,circle] ...

1

You can use the pgf math engine as well: Notes: Besides the siunitx's \num macro you can also use \pgfmathprintnumber to control the formatting of numerical results. Code: \documentclass{article} \usepackage{pgfmath} \usepackage{siunitx} \newcommand{\calcnum}[1]{% \pgfmathparse{#1}% ...

2

Yes. Here's a LaTeX3 implementation: \documentclass{article} \usepackage{expl3, xparse, siunitx} \ExplSyntaxOn \NewDocumentCommand { \calcnum } { O{} m } { \num [ round-mode=places , round-precision=2 , group-separator={,}, group-minimum-digits=4, #1] { \fp_to_decimal:n {#2} } } \ExplSyntaxOff \begin{document} \calcnum{1000.97} ...

5

Here it is! With collcell we pass the cell's content to the \increment macro for being processed. \documentclass{article} \usepackage{xparse,collcell,booktabs} \ExplSyntaxOn \NewDocumentCommand{\increment}{m} { \pushpen_increment_cell:n { #1 } } \seq_new:N \l_pushpen_cell_seq \seq_new:N \l_pushpen_cell_incr_seq \cs_new_protected:Npn ...

3


Top 50 recent answers are included