1

Following on from this answer

My alignment of the first letters was solved. However all variables that have a subscript, have the subscripts too far down example; [x]<subscript text>

Also my \cdots are formatted too high.

Compare my screenshot to the output given by the answer I linked.

Screen shot of my equations and mathjaxx code

code:

$
  \lambda = 
    \small{
      \text{[m]}
    }
    \tiny{
      \text{metres}
    }
$$

$$
  \text{E} = 
    \small{
      \text{[J]}
    }
    \tiny{
      \text{joules}
    }
$$

$$
  \text{h} =
    \small{
      \text{[J]} 
    }
    \tiny{
      \text{joules}
    }\cdot
    \small{
      [\text{s}^{\tiny{-1}}]
    }
    \tiny{
      \text{seconds}
    }
$$

$$
  \text{c} =
    \small{
      \text{[m]} 
    }
    \tiny{
      \text{metres}
    }\cdot
    \small{
      [\text{s}^{\tiny{-1}}]
    }
    \tiny{
      \text{seconds}
    }
$$

$$
  N_A = 
    \small{
      [\text{mol}^{\tiny{-1}}]
    }
    \tiny{
      \text{Avogadro's number}
    }
$$

$$
  \text{c} = 
    \small{
      299792600\ 
      \text{m} \cdot \text{s}^{-1}
    }
$$

$$
  N_A =  
    \small{
      6.0221415\ \cdot\ 10^{23}
    }
$$

$$
  \text{h} = 
    \small{
      6.62607600\ \cdot\ 10^{-34}\ 
      \text{J} \cdot \text{s}^{-1}
    }
$$

enter image description here

code and output given by last answer I linked:


documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
  \lambda &= 
      \mathrm{[m]}
      _{\mathrm{metres}}
\\
  \mathrm{E} &= 
      \mathrm{[J]}
      _{\mathrm{joules}}
\\
  \mathrm{h} &=
      \mathrm{[J]} 
      _{\mathrm{joules}}
    \cdot
      [\mathrm{s}^{-1}]
      _{\mathrm{seconds}}
\\
  \mathrm{c} &=
      \mathrm{[m]} 
      _{\mathrm{metres}}
    \cdot
      [\mathrm{s}^{-1}]
      _{\mathrm{seconds}}
\\
  N_A &= 
      [\mathrm{mol}^{-1}]
      _{\mathrm{Avogadro's\ number}}
\\
  \mathrm{c} &= 
      299792600 
      \mathrm{m} \cdot \mathrm{s}^{-1}
\\
  N_A &=  
      6.0221415 \cdot 10^{23}
\\
  \mathrm{h} &= 
      6.62607600 \cdot 10^{-34}  
      \mathrm{J} \cdot \mathrm{s}^{-1}
\end{align*}
\end{document}

[enter image description here2:

I want to have the same formatting after = from my screenshot, the boxed variables which have subscripts and \cdots using latex.

Update

just 1 minor issue with subscripts.

https://drive.google.com/file/d/1BzpZDnCk6Ypk9zxuy7vcnEUmY898ah_8/view?usp=drivesdk

The lower part of the subscripted letter goes a little bit under my variable box.

The code for each of these equations in order of the screenshot are:

$$[j]_{\text{joules}}$$
$$[j]\small{\text{joules}}$$
$$[j]\tiny{\text{joules}}$$

Is there a way where I could have the subscripted version (first one formatted like the others?

Or a better way to write the last 2?

I know it's really minor but I'm just that type of guy.

17
  • the correct version is as I posted. You have \tiny{ \text{joules} }\cdot which is \tiny \text{joules} \cdot so a tiny cdot which makes no sense as the expression is h=J ⋅ S Jul 4, 2023 at 22:01
  • I already explained why I have the variables the way I do and h=j *s^-1, so it makes sense, all I want is for the \cdots to format properly and the subscript on the boxed variable to appear just like my screenshot, not lower like in yours.
    – Nickotine
    Jul 4, 2023 at 22:14
  • could you please see my screenshot and compare forget about my code being wrong I just want the same formatting
    – Nickotine
    Jul 4, 2023 at 22:16
  • you're answer is correct but many things don't align properly.
    – Nickotine
    Jul 4, 2023 at 22:17
  • subscript means lower, if you don't want it lower remove the _ as I suggested before. Jul 4, 2023 at 22:19

1 Answer 1

2

I think there are two separate issues with your equations.

  • If you do not like the output of _{\mathrm{...}}, I suggest you write \textsubscript{...} instead -- the more so as the subscript materials aren't really mathematical subscripts but, rather, textual side-notes.

    If the output of \textsubscript is too large for your taste, do use \tinytextsubscript instead, where \tinytextsubscript should be defined in the preamble as

    \newcommand\tinytextsubscript[1]{\textsubscript{\tiny #1}}
    
  • You really should switch to using the \num, \unit, and \qty macros of the siunitx package to denote scientific quantities and their associated units. That way, you'll separate the content matters much more effectively and cleanly from formatting matters.


enter image description here

\documentclass{article}

\usepackage{amsmath} % for align* env.
\usepackage{siunitx} % for \num, \unit, and \qty macros
\sisetup{group-digits=false,
         exponent-product={\cdot},  % default is '\times'
         inter-unit-product={\cdot} % optional
        }
\newcommand\avo{N_{\!A}} % snug up "A" to "N"
\newcommand\tinytextsubscript[1]{\textsubscript{\tiny #1}}

\begin{document}

\begin{align*}
  \lambda &= [\unit{\metre}]\tinytextsubscript{metres}  \\
  E       &= [\unit{\joule}]\tinytextsubscript{joules}\\
  h       &= [\unit{\joule}]\tinytextsubscript{joules}
             \cdot
             [\unit{\per\second}]\tinytextsubscript{per second} \\
  c       &= [\unit{\metre}]\tinytextsubscript{metres}
             \cdot
             [\unit{\per\second}]\tinytextsubscript{per second} \\
  \avo    &= [\unit{\per\mol}]\tinytextsubscript{Avogadro's number} \\[1.5ex]
  c       &= \qty{299792600}{\metre\per\second} \\
  \avo    &= \num{6.0221415e23} \\
  h       &= \qty{6.62607600e-34}{\joule\per\second} 
\end{align*}

\end{document}
16
  • I'm new to latex I've only used mathjaxx on stackexchange with the $..$ notation I like this style very much, thanks a lot. How do you upload the output to stack.imgr?
    – Nickotine
    Jul 6, 2023 at 10:29
  • also for per/second is there a way i can get the ^-1 to be smaller?
    – Nickotine
    Jul 6, 2023 at 10:38
  • newcommand\tinytextsubscript[1]{\textsubscript{\tiny #1}} is this how you declare 'functions' in latex for example newcommand\anyName[input]\{\<latex cmd>}{<latexCmdInput> input}?
    – Nickotine
    Jul 6, 2023 at 10:49
  • @Nickotine - I recommend you peruse the user guide of the siunitx package to study how the \per directive can be deployed. Please see any introductory document on LaTeX, such as The Not So Short Introduction to LaTeX by Tobias Oetiker and others, for information on how to define LaTeX macros. TeX is a macro expansion language at heart; hence, it's better to talk about "macros" than about "functions".
    – Mico
    Jul 6, 2023 at 11:16
  • 1
    @Nickotine - I use a MacBook Air that runs MacOS 13.4.1 "Ventura", and my TeX distribution is MacTeX2023 (with all updates applied). pdfLaTeX creates a pdf file by default.
    – Mico
    Jul 6, 2023 at 23:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .