How to make an \underbrace without a brace

mhchemoverbraceunderbrace

I'm trying to write the line diagram of the glass electrodo to measure pH. I've got a working code:

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[version=4]{mhchem}
\begin{document}
\begin{equation*}
\overbrace{\underbrace{\ce{Ag (\textit{s}) | AgCl (\textit{s}) | KCl  (\textit{aq, sat}) }}_{E_{ref1}} \underbrace{||}_{E_j}}^{\text{Electrodo de referencia 1}} \overbrace{\ce{H^+ (\textit{aq}, a_1)}}^{\text{Analito}} \overbrace{\underbrace{|}_{E_1} \text{Membrana de vidrio} \underbrace{|}_{E_2} \textcolor{blue}{\ce{H^+ (\textit{aq}, 0,1M), }} \underbrace{\textcolor{blue}{\ce{Cl^- (\textit{aq}, 0,1 M)}}\ce{|AgCl (\textit{s})|Ag (\textit{s})}}_{\text{Electrodo de referencia 2, }E_{ref2}}}^{\text{Electrodo de vidrio}}
\end{equation*}
\end{document}

and the result look like this:
enter image description here
I need to make it a little more narrow without losing information, and my best option is to save the empty space in the brackets for the interfaces (Ej, E1 and E2).

Is there a way to do that?

Best Answer

To really economize on space, I'd ditch the \underbrace machinery and instead resort to vertical arrows as pointers that direct explanatory stuff towards the items being explained.

enter image description here

\documentclass{article}
\usepackage[margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{xcolor}
\usepackage{mathtools}
\usepackage[version=4]{mhchem}

\begin{document}
\small % so that formula fits within the textblock
\begin{equation*}
\overbrace{%
  \underbrace{\ce{Ag (\textit{s})} \mid 
              \ce{AgCl (\textit{s})} \mid 
              \ce{KCl^{\vphantom{+}}  (\textit{aq, sat})}
             }_{E_{\textrm{ref1}}} 
  %\underbrace{||}_{E_j}
  \underset{\substack{\uparrow\\\mathclap{E_j}}}{\mathrel{\Vert}}
}^{\text{Electrodo de referencia 1}} 
\overbrace{\ce{H^+ (\textit{aq}, a_1)}}^{\text{Analito}} 
\overbrace{%
  %\underbrace{|}_{E_1} 
  \underset{\substack{\uparrow\\\mathclap{E_1}}}{\mid}
  \text{Membrana de vidrio} 
  %\underbrace{|}_{E_2} 
  \underset{\substack{\uparrow\\\mathclap{E_2}}}{\mid}
  \textcolor{blue}{\ce{H^+ (\textit{aq}, 0,1M), }} 
  \underbrace{%
    \textcolor{blue}{\ce{Cl^- (\textit{aq}, 0,1 M)}} \mid 
    \ce{AgCl (\textit{s})}\mid
    \ce{Ag (\textit{s})}
  }_{\text{Electrodo de referencia 2, $E_{\textrm{ref2}}$}}
}^{\text{Electrodo de vidrio}}
\end{equation*}
\end{document}
Related Question