Mathjax rendering issue - math

For an equation, mathjax renders like as shown in image. Please help me to find the problem and fix. In codecogs latex editor, this is rendered properly. In MathType equation editor also it displays well.
Actual code follows.
\begin{align}f(x) &= Sin\: [\pi ]x-Sin[\pi ^{2}]x+Cos[-\pi ^{3}]x \\\\
[\pi ] &=[3.14]=3\\\\ [\pi ^{2}]&=[9.8596]=9\\\\
[-\pi ^{3}]&=[-9.8596]=-10 \\\\
f(\frac{\pi }{6}) &= Sin(3\times \frac{\pi }{6})-Sin(9\times \frac{\pi }
{6})+Cos(-10\times \frac{\pi }{6})\\\\
&=Sin\frac{\pi }{2}-Sin\frac{3\pi }{2}+Cos(\frac{5\pi }{3})\\\\
&= 1-\left ( -1 \right )+\frac{1}{2}\\\\
& =2+\frac{1}{2}\\\\
&=\frac{5}{2} \end{align}

It seems the character [ is causing some problem with align environment and MathJax.
This seems to work for me (at least on JaxEdit and http://math.stackexchange.com):
\begin{align}
f(x) & = Sin(\pi)x - Sin(\pi^2)x + Cos(-\pi^3)*x \\
\left[\pi\right] & = \left[3.14\right] = 3 \\
\left[\pi ^{2}\right] & = \left[9.8596\right]=9 \\
\left[-\pi ^{3}\right] & = \left[-9.8596\right]=-10 \\
f(\frac{\pi }{6}) & = Sin(3\times \frac{\pi }{6})-Sin(9\times \frac{\pi}{6})+Cos(-10\times \frac{\pi }{6})\\
& = Sin\frac{\pi }{2}-Sin\frac{3\pi }{2}+Cos(\frac{5\pi }{3})\\
& = 1-\left ( -1 \right )+\frac{1}{2}\\
& = 2+\frac{1}{2}\\
& = \frac{5}{2}
\end{align}
Or use an equivalent symbole from one of the package that is installed with your MathJax solution

Related

Where are these unexpected characters appearing from in write.table?

I have three strings which I want to bind as rows and pass to the clipboard via write.table(). When I do so I find a lot of junk characters are added and I can't find out where they come from. I'm presuming this is an issue with my setup, but here's the data and code to see if this is reproducible.
strings <- c("\\textit{LTG health} & -.91 (-.91, -.90) & -.90 (-.90, -.90) & -.91 (-.91, -.90) & -.85 (-.86, -.84) & -.91 (-.92, -.91) & -.90 (-.91, -.90) & -.91 (-.91, -.90) & -.85 (-.86, -.84) \\\\",
"\\textit{LLTI} & -.85 (-.85, -.84) & -.84 (-.85, -.83) & -.85 (-.86, -.84) & -.79 (-.80, -.78) & -.84 (-.85, -.83) & -.83 (-.84, -.83) & -.83 (-.84, -.82) & -.77 (-.78, -.76) \\\\",
"\\textit{Mortality (2011)} & -.41 (-.43, -.39) & -.39 (-.42, -.37) & -.41 (-.43, -.39) & -.45 (-.47, -.43) & -.56 (-.58, -.54) & -.54 (-.56, -.52) & -.56 (-.58, -.54) & -.59 (-.61, -.57) \\\\"
)
write.table(strings, "clipboard", col.names = F, row.names = F, quote = F)
When I paste into a plain text editor I get the following full of unexpected characters and the third line appears to be lost entirely. I can't post the actual data because SO is detecting the junk characters as spam, so here's a screenshot:
EDITS
If I use paste() to concatenate into a single row, the junk characters don't appear.
Setting the fileEncoding in write.table to UTF-8 does not fix the problem.

Equation in a table in R

I want a table like this and make it as a kable so I can make footnote:
but I didn't manage so I made a table latex like this :
$$
\begin{array}{lccccc}
\hline
{Copula} & {Distribution} & {Parameter range} & {Complete dependence} & {Independence} \\
\hline
{Normal} & {C_{Normal} (u_1,u_2,\rho)=\Phi_{\rho}(\Phi^{-1}(u_1),\Phi^{-1}(u_2))} & {\rho\in(-1,1)} & {\rho=1,or -1} & {\rho=0} \\
\hline
{Student-t} & {C_t (u_1,u_2;\rho,d)=t_{\rho,d}(t^{-1}_d(u_1),t^{-1}_d(u_2))} & {\rho\in(-1,1)} & {\rho=1,or -1} & {\rho=0} \\
\hline
{Gumbel} & {C_{Gumbel} (u_1,u_2,\beta)=exp\{-[(-ln(u_1))^{\frac{1}{\beta}}+(-ln(u_2))^{\frac{1}{\beta}}]^{\beta}\}} & {\beta\in(0,1)} & {\beta=0} & {\beta=1} \\
\hline
{RG} & {C_{RG} (u_1,u_2,\alpha)=u_1+u_2-1+C_{Gumbel} (1-u_1,1-u_2,\alpha)} & {\alpha\in[1,\infty)} & {\alpha\rightarrow\infty} & {\alpha=1} \\
\hline
{Clayton} & {C_{Clayton} (u_1,u_2,\theta)=max((u_1^{-\theta}+u_2^{-\theta}-1)^{-\frac{1}{\theta}},0)} & {\theta\in[-1,\infty)\{0\}} & {\theta\rightarrow\infty} & {\theta \rightarrow 0} \\
\hline
{RC} & {C_{RC} (u_1,u_2,\alpha)=u_1+u_2-1+C_{Clayton} (1-u_1,1-u_2,\theta)} & {\theta\in[-1,\infty)\{0\}} & {\theta\rightarrow\infty} & {\theta \rightarrow 0} \\
\hline
\end{array}
$$
and it looks like this:
It's not bad until I found it's not easy to add footnotes since I used to make kable.
Is there any way I can add a footnote for it? or how can I convert it into a table so I can use kable to display it?

Remove additional footnote from R's xtable() table output in LaTeX

I am using the following R code to call xtable and generate a LaTeX table for a Sweave document.
ifelse(LaTeX==1, print(xtable(rule1.results.noTC, caption="Rule 1 Results 0 Transaction Costs",
digits=c(1,2,4,4,4), display=c("d","d","f","f","f"))),
print(rule1.results))
This produces the following LaTeX
% latex table generated in R 3.0.1 by xtable 1.7-1 package
% Sun Jul 28 16:54:42 2013
\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
\hline
& L & profits & annCumulExReturn & sharpe \\
\hline
1 & 5 & -888.8215 & -0.1501 & -4.3939 \\
2 & 10 & -909.8941 & -0.1533 & -6.8882 \\
3 & 20 & -893.6245 & -0.1509 & -6.9081 \\
4 & 40 & -865.6764 & -0.1466 & -9.8462 \\
5 & 80 & -832.4700 & -0.1417 & -11.7260 \\
6 & 160 & -757.0690 & -0.1305 & -16.3088 \\
7 & 320 & -626.9162 & -0.1118 & -31.6134 \\
8 & 640 & -340.8740 & -0.0730 & -44.2321 \\
\hline
\end{tabular}
\caption{Rule 1 Results with Transaction Costs}
\end{table}
When I convert this to pdf, I get a nice table. However, it is followed by a weird note:
[1] "
And I get several of these if I plot multiple tables in a row. How can I eliminate this either via R's xtable or by editing the LaTeX code.
Thanks
I can't say for sure without your data and an example of the .tex file, but I'm pretty confident this is due to your use of ifelse. I imagine the following will not give you the weird print out:
if(LaTeX==1) {
print(xtable(rule1.results.noTC,caption="Rule 1 Results 0 Transaction Costs",
digits=c(1,2,4,4,4), display=c("d","d","f","f","f")))
} else {
print(rule1.results))
}
This is because ifelse returns its result, which you're also printing. See, for example:
> ifelse(TRUE,print("true"),print("false"))
[1] "true"
[1] "true"

Basic R - Outputting basic R correlation table -> LaTex or text

I am generating a correlation table with http://myowelt.blogspot.com/2008/04/beautiful-correlation-tables-in-r.html
I am not successful, however, in outputting the file to a usable LaTex file or text file.
I have been unsuccessful using sink() to save the data to a text file.
Suppose I am using the following command:
corstarsl(lpp_axis1)
How would I pipe the output to a text file? I've read the documentation on sink and I'm missing a step somewhere. (I open the connection, execute the command, unlink the file and then I find nothing.)
I've also tried using the output from xtable(cortstarsl(lpp_axis1)) in a tex file yet I receive a "element table not found error. I do not know enough about Tex to track the source of the problem.
Suggestions for outputting this data?
Other suggestions for creating a correlation table?
Using the code from the web page you link to, I get (with the built in airquality data):
> require(Hmisc)
> require(xtable)
> xtable(corstarsl(airquality))
% latex table generated in R 2.12.1 by xtable 1.5-6 package
% Mon Feb 21 20:00:34 2011
\begin{table}[ht]
\begin{center}
\begin{tabular}{rlllll}
\hline
& ozone & solar.r & wind & temp & month \\
\hline
ozone & & & & & \\
solar.r & 0.35*** & & & & \\
wind & -0.60*** & -0.06 & & & \\
temp & 0.70*** & 0.28*** & -0.46*** & & \\
month & 0.16 & -0.08 & -0.18* & 0.42*** & \\
day & -0.01 & -0.15 & 0.03 & -0.13 & -0.01 \\
\hline
\end{tabular}
\end{center}
\end{table}
So the question then is how to get this TeX output to a file. Here capture.output() is one friend:
> capture.output(xtable(corstarsl(airquality)), file = "mytable.tex")
Which outputs the code to file named mytable.tex:
$ cat mytable.tex
% latex table generated in R 2.12.1 by xtable 1.5-6 package
% Mon Feb 21 20:01:03 2011
\begin{table}[ht]
\begin{center}
\begin{tabular}{rlllll}
\hline
& ozone & solar.r & wind & temp & month \\
\hline
ozone & & & & & \\
solar.r & 0.35*** & & & & \\
wind & -0.60*** & -0.06 & & & \\
temp & 0.70*** & 0.28*** & -0.46*** & & \\
month & 0.16 & -0.08 & -0.18* & 0.42*** & \\
day & -0.01 & -0.15 & 0.03 & -0.13 & -0.01 \\
\hline
\end{tabular}
\ end{center}
\end{table}
For "plain" delimited text output, perhaps to dump into a word processor or Spreadsheet, try write.table(), eg:
> write.table(corstarsl(airquality), file = "mytable2.txt")
Which results in a file like this:
$ cat mytable2.txt
"ozone" "solar.r" "wind" "temp" "month"
"ozone" "" "" "" "" ""
"solar.r" " 0.35***" "" "" "" ""
"wind" "-0.60***" "-0.06 " "" "" ""
"temp" " 0.70***" " 0.28***" "-0.46***" "" ""
"month" " 0.16 " "-0.08 " "-0.18* " " 0.42***" ""
"day" "-0.01 " "-0.15 " " 0.03 " "-0.13 " "-0.01 "
You can alter the quoting and delimiter to your heart's content - see ?write.table.

How to do the square root in PowerPoint VBA?

Here is some math code that adds A to B:
Sub math()
A = 23
B = 2
ABSumTotal = A + B
strMsg = "The answer is " & "$" & ABSumTotal & "."
MsgBox strMsg
End Sub
But how can I calculate a square root of ABSumTotal?
Is it possible in PowerPoint VBA?
Use: Sqr()
strMsg = "The answer is " & "$" & Sqr(ABSumTotal) & "."
Have you tried the function Sqr?
See:
http://msdn.microsoft.com/en-us/library/h2h9y284%28VS.85%29.aspx
You can use use ^ to compute X^(1/2)
Edit: added parenthesis

Resources