Tag Info

New answers tagged

1

Disclaimer: I'm trying to answer my own question despite severe lack of knowledge... After a closer examination of related problems, I have found that combining this and that answer serves as an appropriate answer to my question as well (my question might be marked as duplicate although the respective questions go into a slightly different direction). For ...


4

Here's a solution using the pgfcalendar package (part of the pgf bundle.) \documentclass{article} \usepackage{pgfkeys,pgfcalendar} \newcount\julianday \newcount\daycount \newcount\weekday \newcommand*{\adddays}[2]{% \pgfcalendardatetojulian{#1}{\julianday}% \daycount=#2\relax \loop \advance\julianday by 1\relax ...


1

Counters can only contain integer numbers. If you want to deal with real numbers you have to play with lengths. The following MWE uses lengths instead of counters (the internal macro \strip@pt is used to strip pt when printing the length): \documentclass{scrartcl} \usepackage{pbox,calc} \makeatletter \newcommand*{\strippt}[1]{\strip@pt#1} \makeatother ...


4

Updated version: The first version of the code (see below) had one problem: if the box height was too big, then the signs will protrude their corresponding boxes; this can be solved choosing a maximum value for the length of the signs. The following code shows one such possibility; the length is (approximately) the minimum between the height of the box and ...


7

Some number printing fun :) Since there are huge numbers let fpu handle them. I used truncated [.]illionths \documentclass{scrartcl} \usepackage{tikz} \usetikzlibrary{fpu,babel}%TikZ 3 has a babel library that takes care of active chars \pgfkeys{ /pgf/number format/mynum/.style={1000 sep={},std=0:3,sci precision=0, sci generic={mantissa ...


10

Here is a very simple TikZ version (I use named styles to choose between black or white) : \documentclass{scrartcl} \usepackage{tikz} \usetikzlibrary{calc} \tikzset{ square/.style={draw,minimum size=1cm,inner sep=0}, square 0/.style={square,fill=black}, square 1/.style={square,fill=white}, % label/.style={font=\large,align=center,text ...


9

I'd avoid using \color and \textcolor which are important macros in the color and xcolor packages: you might end up in using them, buried in other macros, when typesetting the text of a node. Also some constructions can be simplified: \documentclass{scrartcl} \usepackage{tikz} \usetikzlibrary{calc} \usetikzlibrary{patterns} \begin{document} ...


4

You can define a new command based on \num, exploiting the fact that siunitx uses expl3 internally: \documentclass{article} \usepackage[group-separator={,},group-minimum-digits=4]{siunitx} % \usepackage{xparse} % already loaded by siunitx \ExplSyntaxOn \NewDocumentCommand{\numc}{ O{} m } { \num[#1]{ \fp_eval:n{ #2 } } } \ExplSyntaxOff \begin{document} ...


8

As l3fp is part of the 'code level' expl3 implementation, the documentation is included in interface3: a programmers' reference. As it implements the same arithmetic operations as are (commonly) provided by other languages, the documentation for the individual operations is not that detailed. In terms of 'stability', I'd say that How "safe" is it ...


12

If you also want to print two zeroes after the number use this siunitx setup: \sisetup{group-separator={,},group-minimum-digits=4,round-integer-to-decimal,round-mode=places} MWE: \documentclass{article} \usepackage{siunitx} \begin{document} \newcommand{\MyNumberA}{40} \newcommand{\MyNumberB}{60} ...


11

You can use siunitx package to do this: \documentclass{article} \usepackage[group-separator={,},group-minimum-digits=4]{siunitx} \begin{document} \newcommand{\MyNumberA}{40} \newcommand{\MyNumberB}{60} \num{\the\numexpr(\MyNumberA*\MyNumberB)\relax} \end{document} which produces: You can define your own command to handle this too: ...


3

Please don't do any commercial transaction based on this code. And about getting compile time values, if you run with shell-escape enabled I guess you can run some external software which will pick up the info somewhere and then return it to TeX. But I don't know how one does these things, I am bad at getting money in my direction. this answer does not pay ...


6

You can only use literal numbers in the {n} part and, anyway, an integer cannot be used to get a literal number. You have to fully expand the numeric expression to a decimal number, but you also have to ensure not expanding too much; the best is to do the calculation before passing the argument: \documentclass[a5paper]{article} \usepackage[ngerman]{babel} ...


3

[migrated from comment] As regards your second question: The graphicx package interface keys height and width expect a dimension, not a glue specification. When one tries out your provided code one sees it does not work and that the plus 3cm minus 3cm end up being printed as text.


6

You can use etex capabilities for simple calculations: \numexpr (\MyNumberA + 2* \MyNumberN)/3 \relax ` computes a weighted means of \MyNumberA and \MyNumberB. Similarly, you can do calculations with dimensions, using \dimexpr.


1

You can do all of this using Plain TeX/LaTeX counters. \documentclass{article} \pagestyle{empty}% for cropping \begin{document} \obeylines% \newcount\MyNumber% \MyNumber=30% \def\tp#1{\texttt{\string\MyNumber #1} =}% \tp{} \the\MyNumber \advance\MyNumber by 10\relax% \tp{ + 10} \the\MyNumber \multiply\MyNumber by 100\relax% \tp{ * 100} \the\MyNumber ...


2

I really don't know why but this works for me \documentclass{article} \usepackage{pgfplots} \usetikzlibrary{calc} \pgfplotsset{compat=1.10} \begin{document} \begin{tikzpicture} \begin{axis} \addplot {x*x}; \draw [ultra thick, dotted, draw=brown] (current axis.left of origin) -- (current axis.right of origin); \draw [ultra ...


3

Regarding the main question: pgfplots comes without builtin support for extrapolations. You would need to compute them by means of an external product, maybe octave or matlab.



Top 50 recent answers are included