2

I have trouble with the following code which stems from my somehow faulty use of the \splitfrac environment. Can someone help?

\item $p_{(lon_i,lat_r,jul_a)} = \frac{1}{\splitfrac{1 + e^{-(\beta_0 + \beta_1MeanTempoerature_{(lon_i,lat_r,jul_a)} + \beta_2Altitude_{(lon_i,lat_r,jul_a)} + \beta_3Longtitude_{(lon_i,lat_r,jul_a)})}}{e^{-( + \beta_4Latitude_{(lon_i,lat_r,jul_a)} + \beta_5JulianDate_{(lon_i,lat_r,jul_a)})}}}$ 

A minimal working example follows:

\documentclass{article}
\usepackage{amsmath} 
\usepackage{mathtools}

\begin{document} \begin{itemize} \item $p_{(lon_i,lat_r,jul_a)} = \frac{1}{\splitfrac{1 + e^{-(\beta_0 + \beta_1MeanTempoerature_{(lon_i,lat_r,jul_a)} + \beta_2Altitude_{(lon_i,lat_r,jul_a)} + \beta_3Longtitude_{(lon_i,lat_r,jul_a)})}}{e^{-( + \beta_4Latitude_{(lon_i,lat_r,jul_a)} + \beta_5JulianDate_{(lon_i,lat_r,jul_a)})}}}$ \end{itemize} \end{document}

JamesT
  • 3,169
  • 1
    Welcome to TeX.SE! Can you describe what is your problem? And also provide a minimal complete example? – mickep Mar 02 '23 at 19:02
  • 1
    I think the problem is related to the way I set parentheses. To me, they appear alright. I can safely assert that the rest of the code okay and that all relevant packages are loaded. – RibbitRibbit Mar 02 '23 at 19:15
  • Your code compiles; the math content just runs off the page. So, I don't understand the question when you say "I have trouble... from my faulty use of the \splitfrac{}{} [command]." Can you elaborate? – Werner Mar 02 '23 at 19:24
  • @Werner, that's interesting, I get an error when I compile the code: Undefined control sequence. l.8 \abx@aux@refcontext {nyt/global//global/global}. What error do you get RibbitRibbit, could you edit it into your question please? – JamesT Mar 02 '23 at 19:26
  • 2
    @JamesT: That looks like a faulty .aux. Remove it and try again. – Werner Mar 02 '23 at 19:33
  • Arr ya so I am writing a rmarkdown file and R Studio throws the following error:
    <argument> \splitfrac 
                          {1 + e^{-(\beta _0 + \beta _1MeanTempoerature_{(lon_i,...
    l.99 ...beta_5JulianDate_{(lon_i,lat_r,jul_a)})}}}
                                                      $ 
    
    – RibbitRibbit Mar 02 '23 at 19:37
  • @RibbitRibbit: Then you need to add \usepackage{mathtools} to your YAML header, as is described here: How to include LaTeX package in R Markdown?; specifically, header-includes: -\usepackage{mathtools} – Werner Mar 02 '23 at 19:39
  • @ Werner True. Fortunately all necessary packages are in my yaml header already. – RibbitRibbit Mar 02 '23 at 19:40
  • Off-topic: The mathtools package loads the amsmath package automatically. Hence, no need to load amsmath explicitly. – Mico Mar 02 '23 at 19:58
  • @RibbitRibbit: Then you shouldn't be getting an error. You might consider provided a minimal rmarkdown document that replicates your error. – Werner Mar 02 '23 at 22:21

2 Answers2

5

If you don't want to abbreviate the variable names and the names in the three-part subscripts, I suggest you use two nested \splitfrac statements, so as to split the denominator across three lines, rather than just two lines. For better legibility, I would also replace e^{...} notation with \exp[...] notation.

That said, I think you should abandon the \frac setup entirely and provide an expression for p^{-1} rather than for p. See the second example below.

enter image description here

\documentclass{article}
\usepackage{geometry}  % set page parameters as needed
\usepackage{mathtools} % mathtools loads amsmath automatically
\newcommand{\vn}[1]{\mathrm{#1}}
% handy shortcut macro:
\newcommand{\llj}{(\vn{lon}_i,\,\vn{lat}_r,\,\vn{jul}_a)}

\begin{document}

\begin{itemize} \item $p_{\llj} = \dfrac{1}{\splitfrac{\splitfrac{% 1 + \exp\bigl[-( \beta_0 + \beta_1 \vn{MeanTemperature}{\llj}}{% + \beta_2 \vn{Altitude}{\llj} + \beta_3 \vn{Longitude}{\llj})\bigr] }}{% \times\exp\bigl[-( \beta_4 \vn{Latitude}{\llj} + \beta_5 \vn{JulianDate}_{\llj})\bigr]}}$

\item $\begin{aligned}[t] p_{\llj}^{-1} &= 1 + \exp\bigl[-( \beta_0 + \beta_1 \vn{MeanTemperature}{\llj} \ &\qquad + \beta_2 \vn{Altitude}{\llj} + \beta_3 \vn{Longitude}{\llj})\bigr] \ &\quad \times\exp\bigl[-( \beta_4 \vn{Latitude}{\llj} + \beta_5 \vn{JulianDate}_{\llj})\bigr] \end{aligned}$ \end{itemize} \end{document}

Mico
  • 506,678
  • 1
    That's a useful reply, thank you. Didn't even cross my mind... – RibbitRibbit Mar 02 '23 at 19:53
  • 1
    I would go even further and introduce auxiliary functions p_mean(lon, lat, jul) = exp[...] and p_season(lon, lat, jul) = exp[...] (naming is just a guess). You can then represent the main equation in terms of these. – jpa Mar 03 '23 at 07:29
  • @jpa - That's definitely very good advice for the OP to take to heart. – Mico Mar 03 '23 at 07:53
4

Hm, something like this:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document} \begin{itemize} \item $p_{(lon_i,lat_r,jul_a)} = p_{(llj)} = \frac{1}{\splitfrac{1 + e^{-(\beta_0 + \beta_1 \mathrm{MT}{(llj)} + \beta_2 \mathrm{A}{(llj)} + \beta_3 \mathrm{Lg}{(llj)})}} {e^{-( + \beta_4 \mathrm{La}{(llj)} + \beta_5 \mathrm{JD}_{(llj)})}} } $\par where MT, A Lg , La and JD are MeanTemperature, Altitude, Longitude, Latitude and JulianDate respectively and indexes $llj$ is shortness for $lon_i,lat_r,jul_a$. \end{itemize} \end{document}

Zarko
  • 296,517
  • Ja, I definitely get your motivation to use abbreviations. I want to put as least strain on the reader as possible however, which is my motivation to split the frac instead. – RibbitRibbit Mar 02 '23 at 19:35
  • 1
    @Mico, huh, I blindly copy OP terms ... and not check their spelling :-). Now corrected. Thank you very much for pointing on this tipos. – Zarko Mar 02 '23 at 19:45
  • +1, and kodos for suggesting the "lln" abbreviation. :-) – Mico Mar 02 '23 at 20:03