cfrac2latex | R Documentation |
Take the vectors of numerators and denominators and create the LaTeX formula which will draw the "cascading" continued fraction.
cfrac2latex(denomvals, numvals = 1, denrepeats = 1, doellipsis = FALSE, ...)
denomvals |
A vector containing the denominator values, starting with the not-actually-denominator integer part of the continued fraction. If the denominator has a repeat sequence, specify the number of repeats using the argument |
numvals |
A vector containing the numerator values. If the length of this vector is less than the length of the (perhaps repeated) |
denrepeats |
If the denominator sequence has a repeat pattern, repeat that pattern this many times. See the Details section for more information. |
doellipsis |
If TRUE, an ellipsis is printed in the deepest denominator, indicating an infinite sequence continues. If FALSE, not added. |
... |
Reserved for future upgrades |
The standard notation for a continued fraction defines a sequence [a0; b1, b2, b3,...bn] indicating the formula is x = a0 + 1/(b1 + 1/(b2 + 1/(b3...))) (or replace the numerators with a specified sequence of values of length n). To save input effort, if there's a repeat pattern, e.g. [a0,b1,b2,b3,b1,b2,b3,...] then the user can enter the vector denomvals = c(a0,b1,b2,b3)
and enter the desired number of repeats with the argument denrepeats
.
Three versions are returned.
texeqn
contains a text string compatible with the R-console's parser. Use this to write the correct LaTeX string to a file, or to pass it to tools such as title
.
tex2copy
can be used if you wish to use Select/Copy/Paste operations on the text displayed in the console. Do not enter this into any R command, as the parser will interpret the backslashes as escape characters, e.g. "backslash-f" turns into a newline.
Finally, eqn
returns an ASCII-only string along the lines of "1/(1+1/(2+1/(3+...)))" .
Carl Witthoft, carl@witthoft.com
cfrac2latex( 1:5,1, doellipsis= FALSE)
#$eqn
#[1] "1 + 1/(2 + 1/(3 + 1/(4 + 1/5 ...)))"
#$tex2copy
#[1] "1 + \frac{1}{2 + \frac{1}{3 + \frac{1}{4 + \frac{1}{5 ...}}}}"
# Notice the additional backslashes to make the console parser happy.
#$texeqn
#[1] "1 + \frac{1}{2 + \frac{1}{3 + \frac{1}{4 + \frac{1}{5 ...}}}}"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.