Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing a mathematical equation in LaTeX but want some of the symbols to be represented by dotted line segments. In practice I want to use \sqcup, which consists of three line segments, and want each of them to be replaced by a dotted line. Could anyone tell me how to do this?

share|improve this question
    
it seems I could use tikz to do this, but hopefully there is a simpler option. In any case any suggestion is welcome. –  masa Sep 30 '12 at 13:41

1 Answer 1

up vote 4 down vote accepted

It is a TikZ solution.

Code

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{calc}

\newcommand*\Dottedsqcupmaxdots{7}
\newcommand*\Dottedsqcupcircleradius{.7\pgflinewidth}
\newcommand*\DottedSqCupsquarefactor{1.8}
\newcommand*\everyscquphspace{\mspace{1.2mu}} % needs amsmath

\newbox\boxdottedsqcup
\newbox\boxDottedsqcup
\newbox\boxDottedSqcup
\newbox\boxDottedSqCup

\savebox\boxdottedsqcup{\ensuremath{\everyscquphspace}\tikz{\draw[dash pattern=on \pgflinewidth off \pgflinewidth] (0,14.5\pgflinewidth) -- (0,0) -- (12\pgflinewidth,0) -- + (0,14.5\pgflinewidth);}\ensuremath{\everyscquphspace}}
\savebox\boxDottedsqcup{%
    \ensuremath{\everyscquphspace}%
    \tikz{
        \foreach \x in {0,...,\Dottedsqcupmaxdots} {
            \fill (0,2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
            \ifnum\x<\numexpr\Dottedsqcupmaxdots-1\relax
                \fill (2*\x*\pgflinewidth,0) circle (\Dottedsqcupcircleradius);
            \fi
            \pgfmathparse{2*(\Dottedsqcupmaxdots-1)*\pgflinewidth}
            \fill (\pgfmathresult pt,2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
        }
    }%
    \ensuremath{\everyscquphspace}%
}
\savebox\boxDottedSqcup{%
\ensuremath{\everyscquphspace}%
    \tikz{
    \pgfmathparse{\Dottedsqcupmaxdots-1}
        \foreach \x in {0,...,\pgfmathresult} {
            \fill (0,2.2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
%           \ifnum\x<\numexpr\Dottedsqcupmaxdots-1\relax
                \fill (2.2*\x*\pgflinewidth,0) circle (\Dottedsqcupcircleradius);
%           \fi
            \pgfmathparse{2.2*(\Dottedsqcupmaxdots-1)*\pgflinewidth}
            \fill (\pgfmathresult pt,2.2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
        }
    }%
    \ensuremath{\everyscquphspace}%
}
\savebox\boxDottedSqCup{%
    \ensuremath{\everyscquphspace}%
    \tikz{
    \pgfmathparse{\Dottedsqcupmaxdots-1}
        \foreach \x in {0,...,\pgfmathresult} {
            \fill (0,2.2*\x*\pgflinewidth) ++(135:\Dottedsqcupcircleradius) rectangle +(\DottedSqCupsquarefactor*\Dottedsqcupcircleradius,-\DottedSqCupsquarefactor*\Dottedsqcupcircleradius);
%           \ifnum\x<\numexpr\Dottedsqcupmaxdots-1\relax
                \fill (2.2*\x*\pgflinewidth,0) ++(135:\Dottedsqcupcircleradius) rectangle +(\DottedSqCupsquarefactor*\Dottedsqcupcircleradius,-\DottedSqCupsquarefactor*\Dottedsqcupcircleradius);
%           \fi
            \pgfmathparse{2.2*(\Dottedsqcupmaxdots-1)*\pgflinewidth}
            \fill (\pgfmathresult pt,2.2*\x*\pgflinewidth) ++(135:\Dottedsqcupcircleradius) rectangle +(\DottedSqCupsquarefactor*\Dottedsqcupcircleradius,-\DottedSqCupsquarefactor*\Dottedsqcupcircleradius);
        }
    }%
    \ensuremath{\everyscquphspace}%
}

\newcommand*{\dottedsqcup}{\mathbin{\usebox\boxdottedsqcup}}
\newcommand*{\Dottedsqcup}{\mathbin{\usebox\boxDottedsqcup}}
\newcommand*{\DottedSqcup}{\mathbin{\usebox\boxDottedSqcup}}
\newcommand*{\DottedSqCup}{\mathbin{\usebox\boxDottedSqCup}}

\begin{document}\noindent
\(1\sqcup2\)\\
\(1\dottedsqcup 2\)\\
\(1\Dottedsqcup 2\)\\
\(1\DottedSqcup 2\)\\
\(1\DottedSqCup 2\)
\end{document}

Output

enter image description here

share|improve this answer
    
I guess it should be \mathbin –  egreg Sep 30 '12 at 14:13
    
Thank you, I will install tikz and try this! –  masa Sep 30 '12 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.