hi i am using latex and texmaker to do the following:
$\mathcal{a( X, Y )= a_i \circ a_j}$
which i expect to get
a(X,Y)= a subscript {i} circle a subscript {j}
but instead i get weird signs instead for a's (on the right side of equation), i and j ...can you tell me why? thanks...
The problem is that \mathcal only works on upper case letters.
never mind i did
$a(X,Y)=a_i \circ a_j$
it solved the problem.
thanks anyways!
Related
/^a-bc+d*ef
I am little bit confused about this expression
*ef=(e*f)
+d*ef=d+(e*f)
-BC=(b-c)
/^a? if it is ^23= 2^3
here I am confused, what should I do? please need help.
/^a-bc+d*ef
/^a-bc+d(e*f)
Here now what should i do? should /^a-bc+d+(e*f) is this okay?
(b-c) then what sign should be between /^a(b-c) and d+(e*f)?
and /^a I know if ^23=2^3=8
but here I am totally fed up. Please guide me where i am wrong.
It seems to me that your expression is not correct:
/^a-bc+d*ef
<=>
/^a-bc+d(e*f)
<=>
/^a-bc (d+(e*f))
At this point you've got three values in a row and no operator. All operators should be binary for Polish notation to work.
I need to remove all \text generated by TeXForm in Mathematica.
What I am doing now is this:
MyTeXForm[a_]:=StringReplace[ToString[TeXForm[a]], "\\text" -> ""]
But the result keeps the braces, for example:
for a=fx,
the result of TeXForm[a] is \text{fx}
the result of MyTeXForm[a] is {fx}
But what I would like is it to be just fx
You should be able to use string patterns. Based on http://reference.wolfram.com/mathematica/tutorial/StringPatterns.html, something like the following should work:
MyTeXForm[a_]:=StringReplace[ToString[TeXForm[a]], "\\text{"~~s___~~"}"->s]
I don't have Mathematica handy right now, but this should say 'Match "\text{" followed by zero or more characters that are stored in the variable s, followed by "}", then replace all of that with whatever is stored in s.'
UPDATE:
The above works in the simplest case of there being a single "\text{...}" element, but the pattern s___ is greedy, so on input a+bb+xx+y, which Mathematica's TeXForm renders as "a+\text{bb}+\text{xx}+y", it matches everything between the first "\text{" and last "}" --- so, "bb}+\text{xx" --- leading to the output
In[1]:= MyTeXForm[a+bb+xx+y]
Out[1]= a+bb}+\text{xx+y
A fix for this is to wrap the pattern with Shortest[], leading to a second definition
In[2]:= MyTeXForm2[a_] := StringReplace[
ToString[TeXForm[a]],
Shortest["\\text{" ~~ s___ ~~ "}"] -> s
]
which yields the output
In[3]:= MyTeXForm2[a+bb+xx+y]
Out[3]= a+bb+xx+y
as desired.
Unfortunately this still won't work when the text itself contains a closing brace. For example, the input f["a}b","c}d"] (for some reason...) would give
In[4]:= MyTeXForm2[f["a}b","c}d"]]
Out[4]= f(a$\$b},c$\$d})
instead of "f(a$\}$b,c$\}$d)", which would be the proper processing of the TeXForm output "f(\text{a$\}$b},\text{c$\}$d})".
This is what I did (works fine for me):
MyTeXForm[a_] := ToString[ToExpression[StringReplace[ToString[TeXForm[a]], "\\text" -> ""]][[1]]]
This is a really late reply, but I just came up against the same issue and discovered a simple solution. Put a space between the variables in the Mathematica expression that you wish to convert using TexForm.
For the original poster's example, the following code works great:
a=f x
TeXForm[a]
The output is as desired: f x
Since LaTeX will ignore that space in math mode, things will format correctly.
(As an aside, I was having the same issue with subscripted expressions that have two side-by-side variables in the subscript. Inserting a space between them solved the issue.)
Found another question that seemed to be solved by using .sprintf('%02d', 1) to solve this, but I get: 'private method `sprintf' called for 7:Fixnum'.
Does this mean sprintf cant be called on an integer or am I getting it wrong in the calling?
Just looking to pad single digit returns with a leading 0.
Thanks in advance for any help on this!
You might want to try using sprintf like this:
sprintf('%02d', 1)
# => "01"
ie
sprintf('%02d', model.count)
Not calling .sprintf on the number but rather inputing it as a parameter into sprintf()
you may want to try "0#{num}"[-2..-1] or "%02d" % 1
I have the following code in an attempt to align things in latex using amsmath package:
\begin{alignat}{3}
\text{max} && c^Tx &=\\
\text{s.t.} && Ax &\leq b \\
&& x &\geq 0
\end{alignat}
Basically, i would like for max and s.t. to be in one column, c^Tx, Ax, x to be in second column, and lastly b and 0 to be in the last column. I'm not sure why it doesn't work (it clumps max and c^Tx together for some reason.
if anyone can help me out with this it would be much appreciated!
With math-mode \text{} you should put in some explicit whitespace such as \quad. But max smells like a log-like symbol so you should be using pre-defined \max or self-defined \operatorname{max} instead of \text{max}.
Additionally, the parameter for the alignat environment should be 2 in this case. The param is the number of alignment structures and can be calculated by solving n from a=2n-1 where a is the number of ampersands on a row. However, it doesn't seem to have a difference in this case.
I believe what's happening here is that max and s.t. are being right-aligned, which is running them right up next to c^Tx and Ax. If you just add some whitespace to the right-hand-side of max and s.t., you should be in business.
(Also, laalto is right, you should definitely use \operatorname{max} if max is some sort of operator or function. Though I'm not really sure what you're doing, so maybe it isn't.)
I'm writing a parser for a very simple grammar in javacc. It's beginning to come together but at the moment I'm completely stuck on this error:
ParseException: Encountered "" at line 4, column 15.
Was expecting one of:
The line of input in question is z = y + z + 5
and the production that is giving me problems is my expression which get called from
varDecl():
<ID> <EQL> expression()
Expression looks like this:
<VAR> (<PLUS> expression())?| <NUM> (<PLUS> expression())?
| call() (<PLUS> expression())?
I'm at a loss as to why I'm getting this error - any insight would be greatly appreciated.
Hm, yes, that's not a very helpful error from JavaCC. What version of JavaCC are you using?
Also, it's difficult to troubleshoot these problems without seeing the full grammar... and although I understand you might not be in a position to post that.