3

I've been looking for a way to typeset the parallel of two resistances. I'm aware of the \parallel symbol, but it has the limitation that it won't adapt its size; i.e., the following MWE won't compile:

\documentclass{article}
\begin{document}
    \[
        \left.\frac{1}{g_m}\right\parallel\frac{1}{g_m}
    \]
\end{document}

I tried defining a new command

\documentclass{article}
\newcommand{\parallelTwo}[2]{\left.#1\right|\left|#2\right.}
\begin{document}
    \[
        \left.\frac{1}{g_m}\right\parallel\frac{1}{g_m}
    \]
\end{document}

but clearly the result is not what I intend, because the size of each line is different:

Failed parallel command

How could this be refined? Ideally, the command would accept an arbitrary number of arguments and adapt the parallel symbol to the size of the biggest argument, using the correct spacing.

Here is a remotely related question: How to draw the “parallel circuits” sign “//”?

2
  • If you must use this notation (as opposed to $\frac{R}{1+Rg_m}$), shouldn't you put parenthesis around it? After all, one can have more than two impedances in parallel. Jan 16, 2016 at 17:59
  • @JohnKormylo It depends on the context, this is just a MWE.
    – Noitaenola
    Jan 16, 2016 at 18:27

2 Answers 2

2

You can use \DeclarePairedDelimiterX from mathtools, with an adjustment because the command doesn't really like empty delimiters:

\documentclass{article}
\usepackage{mathtools,xparse}

\DeclarePairedDelimiterX{\parallelTwoAux}[2]{.}{.}{%
  #1\nonscript\;\delimsize\Vert\nonscript\;#2%
}

\NewDocumentCommand{\parallelTwo}{somm}{%
  \IfBooleanTF{#1}
    {\parallelTwoAux*{#3}{#4}}
    {\IfNoValueTF{#2}
       {#3 \parallel #4}
       {\parallelTwoAux[#2]{#3}{#4}}%
    }%
}

\begin{document}

\[
\parallelTwo{R}{x}
\quad
\parallelTwo[\Big]{R}{\frac{1}{g_m}}
\quad
\parallelTwo*{R}{\frac{1}{g_m}}
\]

\end{document}

enter image description here

2

See if the following solve your problem:

\documentclass{article}

\newcommand{\parallelTwo}[2]{\left.#1\,\middle|\!\middle|\,#2\right.}

\begin{document}
    \[
        \parallelTwo{R}{\frac{1}{g_m}}
    \]
\end{document}

enter image description here

Edit: Added fine tuning of spaces around of "parallel" symbol. Similarly can be defined \newcommand for three parallel elements. For more parallel elemets one way is to define:

\newcommand{\parallelE}{\,\middle|\!\middle|\,}

and use it on the following way:

\[
    \left.R_1\parallelE R_2 \parallelE \frac{1}{g_m}\right.
\]
1
  • Thank you. That is a nice workaround. But I wouldn't know how to extend this to accept three parameters and still get the size right. Besides, had to manually adjust the space: \newcommand{\parallelTwo}[2]{\left.#1\hspace{1pt}\middle|\hspace{-1.35pt}\middle|\hspace{1pt}#2\right.}
    – Noitaenola
    Jan 16, 2016 at 18:27

You must log in to answer this question.

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