Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id v0GAPUBO003412 for ; Mon, 16 Jan 2017 11:25:31 +0100 Received: from relay2.uni-heidelberg.de ([129.206.119.212]) by mx-ha.gmx.net (mxgmx004 [212.227.15.9]) with ESMTPS (Nemesis) id 0M4T6q-1ccs5n3w8S-00yhyB for ; Mon, 16 Jan 2017 11:25:24 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.15.2/8.15.2) with ESMTPS id v0GANuaY026558 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Jan 2017 11:23:57 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id v0G6QKa9027772; Mon, 16 Jan 2017 11:23:56 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 15337618 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 16 Jan 2017 11:23:56 +0100 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id v0GANuKq016749 for ; Mon, 16 Jan 2017 11:23:56 +0100 Received: from smtp4.clear.net.nz (smtp4.clear.net.nz [203.97.37.64]) by relay.uni-heidelberg.de (8.15.2/8.15.2) with ESMTP id v0GANlQb027458 for ; Mon, 16 Jan 2017 11:23:51 +0100 Received: from mxin1-orange.clear.net.nz (lb1-srcnat.clear.net.nz [203.97.32.236]) by smtp4.clear.net.nz (CLEAR Net Mail) with ESMTP id <0OJV00HIRBJKAS40@smtp4.clear.net.nz> for LATEX-L@listserv.uni-heidelberg.de; Mon, 16 Jan 2017 23:23:46 +1300 (NZDT) Received: from 118-92-84-227.dsl.dyn.ihug.co.nz (HELO [127.0.0.1]) ([118.92.84.227]) by smtpin1.clear.net.nz with ESMTP; Mon, 16 Jan 2017 23:23:43 +1300 MIME-version: 1.0 Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit X-Antivirus: avast! (VPS 170115-0, 15/01/2017), Outbound message X-Antivirus-Status: Clean References: <587C1AD1.1040401@clear.net.nz> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 Message-ID: <587C9F2F.7020507@clear.net.nz> Date: Mon, 16 Jan 2017 23:23:43 +1300 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Andrew Parsloe Subject: Re: Distinguishing display styles in math mode To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:FTxjnNyKBxM=:nPsdnsbPGxtCKBlL2kFj2vuJZI PKEm/h+ssSmCbtjbI00VxQLZ9+CogiUC68RSrZ32yyZMzWpm8xIxyXlT2yt0wd/h/4f6Vce0j CQ+ARKVKFGZIu95IkxR+ZclOiZiC11nKKoaADi4mB1Thq+/Btl8RFztMfev3LIOpCbhiheOh0 ZvkTScLyUsSVZz4x13P1YGRH+/bYFey6ZRcL/KvNZ05jYpSjdUe7Buwv6eIbX2j37I7Edrlos A9Xvv2TrCat3tlSdXYZcXqA9jAyPtr5cFy6p+txfCaLxGKyDBUzMIMxo0aPp4ivfyEm5xJwHV zegqiPRM+0W+Dz+oXRlXoJ0fVGROUguFr/P9jEEMFUxNNNDsjHxW7CepI4kRLlgkHcVrkoOr/ ep9+OerHktGGtgsLzeDip+DzBR7gm0hH1MHDRNauOxBbKaLkOFwSU/webxZGVBCtM7+CpOJGY T8sIbihehpTDNMhqMYIBb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B8tL uxe1tRxtmvixnHQQF4p2LSsEWsDMbcC/Xbw/lWidFPfx0ur4Bc/50Rv2+oUqKig4CIndZtDkH oirAhj/2FpZZq8j51hPrqI/4OYopyBfeiNbQ8xntdu/1JcgYLGhNSm7+0S/Rj7qsIiKGiSPm4 zdh01FJMr5//IUyyttDNfEo X-UI-Loop:V01:zS7VBHA6/pU=:BFRWuzi5Xrqe+ejXsD5IKResYFnX8WvyIqBD8GKNHjE= X-UI-Out-Filterresults: notjunk:1;V01:K0:8cxfpqfUaqQ=:TZVHGUyB679KnU1VXFN9VK ajNqxg7R5DM50LqBQpOochWj1mCQbJPzaBUmeVg38ca7dwCw2fjZnsY4OegguaBuxeOKp+EAJ HN+b97P7gAzn9QPixWbcf+gdhfMVb2+lBUYV436A1/mFp8UENm7/PGDjEF/zjdBtfzDRegOG9 gBjMgDmOtOrdjs9v1PjGxAZY9fVG/SwgLJeJJTrgo9ck0RJFYIYXNdZAxH1LdphKvtzehkWCo tI4IFRVkS1Fnp1qT9/B8XMgur6tAU5q6a76Lu7IZ8JH0ExtdBDXs2dcTC/NDeXHXRJa1VJtuv odQZeYx9EK1yp5p+3Q7XUBJ5ZJnrJeebjxScP+fsj+t0nETreJBahj6OzKcKf9z3TuRW0hrq8 U0bZXPHyfwtZwPdO09V5orAUqdxSSwHF5KENykZaSQ6TVMy3Unyx2d6xD6u/hyWavFsNdxzgZ 7rq9wuChAhEkLTP4mEmdZA+Kg3FY9XRpVLf3jIjVaSUaNG09aZczViSiee+IX5aJ1OtVfkizd YbUPWa3BmBuWYPsRgbMukHoBn9QIo4zOrn1On+rVa0J X-Scanned-By: MIMEDefang 2.71 on 85.214.41.38 Status: R X-Status: X-Keywords: X-UID: 7939 On 16/01/2017 9:36 p.m., Joseph Wright wrote: > On 16/01/2017 08:19, David Carlisle wrote: >> On 16/01/2017 00:58, Andrew Parsloe wrote: >>> Only recently have I learnt to distinguish inline from display-style >>> maths mode by using \mode_if_inner:TF. It would be helpful for those of >>> us who come to expl3 programming without a good prior grounding in TeX >>> if a comment to this effect could be added to the documentation >>> (interface3.pdf). >>> >>> Andrew >> >> \mode_if_inner:TF is a wrapper around \ifinner so can't be used to >> distinguish inline from display. In fact in math \ifinner can't be used >> to detect much useful at all, the points at which tex is or is not in >> inner math mode are not usually interesting. (Unlike testing for inner >> when in vertical mode that tells you if you are in a box or on the main >> vertical list) > > Indeed, one cannot be sure that display math mode will actually be used > for any 'display' anyway. See for example the strategy used by breqn: > all typesetting is done in inline math mode, using \displaystyle where > appropriate. (Display math mode is used only for obtaining the length of > the line of text immediately preceding the 'display'.) > > Almost certainly you want to use \mathchoice (currently there is no > interface for this in expl3 beyond the primitive), though you might also > look at LuaTeX's additional primitives in this area if you are > considering a 'LuaTeX-only' solution. > > Joseph > I had forgotten \mathchoice. I'm not qualified to argue about the use of \mode_if_inner:TF beyond saying that it has correctly worked to date. *All* the cases of interest to me are of the following kind. #1 is a token list digestible by \fp_eval:n (usually with more * and parentheses than are strictly needed); #2 is a token list consisting of digits and a decimal point (in fact the rounded decimal number resulting from the fp evaluation of #1). Andrew \documentclass{article} \usepackage{expl3,xparse,amsmath} \begin{document} \ExplSyntaxOn \DeclareDocumentCommand \testinner { m m } { \mode_if_inner:TF { \mbox{#1} \to\quad { #2 } } { \begin{aligned} \mbox{#1} & \to \\ & { #2 } \\ \end{aligned} } } \ExplSyntaxOff This is an inline $ \testinner { 2*sin(pi/12)*cos(pi/12) } {2\sin(\pi/12)\cos(\pi/12)=0.5 } $ expression. This is a \[ \testinner { 2*sin(pi/12)*cos(pi/12) } { 2\sin(\pi/12)\cos(\pi/12)=0.5 } \]display-style expression. \end{document} --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus