I have a command which needs a math environment to be used.  But sometimes I want to use it in a text environment and so, I need to create the math environment :   words words words \( \myFunction \) words words   How to detect in which environment I am ?   I want to be able to do :  words words words \myFunction words words   and  \( 1+2 = \myFunction \)
I'm using the package braket for my physics notes, and this speeds things up a great deal but I'm constantly writing \ket{\psi} or \bra{\psi}, and because this specific pair of bra and ket appears so often, this gets repetitive and I would like a macro to speed this up.  However since the braket package works only in math mode, my attempt \newcommand{\ketp}{$\ket{\psi}}$ work when I'm writing in text mode, but when I'm writing in mathmode it breaks (unsurprisingly).  Is there any way I can get this command to work in both mathmode and textmode without having to define two different macros, one for each?    Thanks in advance for any help.  P.S. I'm certain this is a very simple question but I could find little to no explanation of this feature.
Minor "you have already raised this type of flag" bug? I flagged something as spam, then was only 90% sure I'd done so, so I clicked the flag link again to check. It showed me this:    I had, of course, only raised the spam flag, not the offensive/abusive/hate flag, so the latter probably shouldn't be saying I did.    Ah, this may be a duplicate, I didn't search enough:        And if so, it's been around a while. Why does this sort ignore the +/- character prefix? Not booting from USB or CD (SYSLINUX Message) How do I install pepper-flash on Chromium? I have Chromium web browser on my Lubuntu 13.04 (pre-installed).  I use LX Terminal (pre-installed) to write commands. I am trying to download flash player on Chromium using instructions on this :  sudo add-apt-repository ppa:skunk/pepper-flash   After typing in my password, this worked. Now   sudo apt-get update   I didn't need to type in my password, as I continued on the same terminal, but got W:/ and E:/ fetch file errors  sudo apt-get install pepflashplugin-installer   I continued on the same terminal despite the fetch file errors... and they said pepflashplugin-installer could not be found.  Is the last error because of fetch file errors, or because I need to download pepflash-plugin-installer somewhere? Or is it because of something else?  I cannot download the Chrome browser, and not looking to use flash player on my Firefox web browser (installed using lubuntu software center). How do you handle "that that"? The double "that" problem Have you ever had a case where you felt compelled to include strange things like a double that in a sentence? If so, then what did you do to resolve this?  For me, I never knew whether it was acceptable grammar. However, what I did learn was that it was a logic distractor, could lead to confusion, and therefore should be reworded to avoid this. When do I use a dot, arrow, or double colon to refer to members of a class in C++? Probability of a painted cube being reassembled into itself Suppose 27 cubes are stacked together, suspended in the air, to form a larger cube.  The cube is then painted on all the exposed surfaces and dried.  The smaller cubes are then randomly permuted in both spatial position and spatial orientation to form another large cube.  What is the probability that new larger cube is identical to the original?  This is not homework, it was passed on by a friend who found it somewhere on the internet, and they do not remember where. "Seen" status is earlier than the user's last post I posted what I think is a clever answer to:    But then I noticed the question was posted a while ago on Mar 2.  I wanted to see what the chance of the user logging back in and seeing my answer, but the  says the user was seen on Feb 19.  I thought this was supposed to be the date they last logged in? How could they have asked a question on Mar 2 if they haven't logged in since February?  Thanks How can I get form data with JavaScript/jQuery? Monty hall problem extended. I just learned about the Monty Hall problem and found it quite amazing. So I thought about extending the problem a bit to understand more about it. In this modification of the Monty Hall Problem, instead of three doors, we have four (or maybe $n$) doors, one with a car and the other three (or $n-1$) with a goat each (I want the car).  We need to choose any one of the doors. After we have chosen the door, Monty deliberately reveals one of the doors that has a goat and asks us if we wish to change our choice.  So should we switch the door we have chosen, or does it not matter if we switch or stay with our choice?  It would be even better if we knew the probability of winning upon switching given that Monty opens $k$ doors. How to auto close LWC quick action from JavaScript? Efficiently selecting a set of random elements from a linked list Google App Engine: Is it possible to do a Gql LIKE query? How do I use the Chinese remainder theorem to find all the square roots of 11 in $\mathbb Z_{35}$? INNER JOIN ON vs WHERE clause I've been studying the Huddleston and Pullum book for four months now. So far only one thing confuses me: the identity of gerund. Is it a noun or a verb?        His constant smoking upset me.  smoking seems  noun because of adjective constant.   Him/His constantly smoking upset me. smoking seems to be verb because of adverb constantly.   Him/His smoking cigars upset me. smoking seems to be a verb because of object cigars.      "His smoking upset me." So is this smoking gerund a noun or verb? Because there is no differentiation, is it both verb and noun? Maybe it's new word category?  Also his seems to be both  sometimes a subject and at other times a possessive determiner. Is that correct? In Bishop's book "Pattern Classification and Machine Learning", it describes a technique for regularization in the context of neural networks. However, I don't understand a paragraph describing that during the training process, the number of degrees of freedom increases along with the model complexity. The relevant quote is the following:     An alternative to regularization as a way of controlling the effective   complexity of a network is the procedure of early stopping. The   training of nonlinear network models corresponds to an iterative   reduction of the error function defined with respect to a set of   training data. For many of the optimization algorithms used for   network training, such as conjugate gradients, the error is a   nonincreasing function of the iteration index. However, the error   measured with respect to independent data, generally called a   validation set, often shows a decrease at first, followed by an increase as the network starts to over-fit. Training can therefore be   stopped at the point of smallest error with respect to the validation   data set, as indicated in Figure 5.12, in order to obtain a network   having good generalization performance. The behaviour of the network   in this case is sometimes explained qualitatively in terms of the   effective number of degrees of freedom in the network, in which this   number starts out small and then to grows during the training process,   corresponding to a steady increase in the effective complexity of the   model.   It also says that the number of parameters grows during the course of training. I was assuming that by "parameters", it refers to the number of weights controlled by the network's hidden units. Maybe I'm wrong because the weights are prevented to increase in magnitude by the regularization process but they don't change in number. Could it be referring to the process of finding a good number of hidden units?  What's a degree of freedom in a neural network? What parameters increase during  training? Passive voice phrasing of "The bottle contains two liters" A question on $p$-groups, and order of its commutator subgroup. $\textbf{QUESTION-}$ Let $P$ be a p-group with $|P:Z(P)|\leq p^n$. Show that $|P'| \leq p^{n(n-1)/2}$.  If $P=Z(P)$ it is true. Now let $n &gt; 1$, then  If I see $P$ as a nilpotent group and construct its upper central series, it will end , so let it be,  $e=Z_0&lt;Z_1&lt;Z_2&lt;......&lt;Z_r=P$   Now as $Z_{i+1}/Z_i=Z(P/Z_i)$, so if if I take some $x\in Z_2$\ $Z_1$ then $N$={$[x,y]|y\in P$} $\leq Z_1(P)$ and $N \triangleleft P $, so $P/N$ is a group with order $\leq p^{n-1}$.  Now if I let $H=P/N$ then obviously |$H/Z(H)$|$\leq p^{n-1}$.  Now $H'\cong P'N/N \cong P'/(P' \cap N)$ so from here I could finally bring $P'$ atleast into the picture, now |$P'$|=$|H'|.|P'\cap N|$ so $|P'|\leq |H'||N|$.   This is where I am $\textbf{STUCK}$  Now , from here how can I calculate or find some power $p$ bounds on $|H'|$ and $|N|$ so i could get my result. Send email with an attachment located in Google Drive I want to send a PDF attachment located on Google Drive from a Sheet.   Code I'm using is:  function sendEmails() {   var sheet = SpreadsheetApp.getActiveSheet();   var startRow = 2;  // First row of data to process   var numRows = 8;   // Number of rows to process   // Fetch the range of cells A2:B3   var dataRange = sheet.getRange(startRow, 1, numRows, 2)   // Fetch values for each row in the Range.   var file = DriveApp.getFilesByName('ScriptCarPass.pdf')   var data = dataRange.getValues();   for (i in data) {      var row = data[i];     var emailAddress = row[0];  // First column     var message = row[1];       // Second column     var subject = "Sending emails from a Spreadsheet";     MailApp.sendEmail(emailAddress, subject, message, {attachments: file});   } }   Everything works fine except the attachment - i.e. if I run without the attachment it works fine.  I keep getting error Invalid argument: inlineImages  I've also tried with:   attachments: [file.getAs(MimeType.PDF)]   but that gives error that .getAs isn't recognised.