# Can Manipulate parameters be hidden with an If statement? [duplicate]

I'm making a demonstration with the following code:

a = Pi/4;
b = 3 Pi/2;
f[x_, n_] = Piecewise[{{x + Sin[x] + n, x >= Pi}, {x + Sin[x], x < Pi}}];
Manipulate[
Plot[
f[x, n], {x, -Pi, 2 Pi + 1},
PlotRange -> {{-1, 2 Pi + 1}, {-1, 2 Pi}},
Epilog -> {
Table[{Dotted, Line[{{-1, q}, {2 Pi + 1, q}}]}, {q, {f[a, n], f[b, n]}}],
If[n == 0, {Dashed, Line[{{-1, f[c, n]}, {2 Pi + 1, f[c, n]}}]}, {Dashed, Line[{{-1, k}, {2 Pi + 1, k}}]}]
},
Ticks -> False,
Axes -> False
],
{{n, 0}, {0, Pi/2}},
{{c, Pi}, a, b},
{{k, f[a, n], "K"}, f[a, n], f[b, n]}
]


When n=0 is selected, the k slider does nothing; when n=Pi/2, the c slider does nothing. Is there some way to hide the k and c sliders under the conditions for which they're inactive?

(Bonus points: For convenience, I'd like to post an animation of what happens for users who can't run it in Mathematica on their own, so if someone could post instructions or a link to where I can learn to make a screen-cap, I would greatly appreciate it!)

## marked as duplicate by Dr. belisarius, dr.blochwave, m_goldberg, Bob Hanlon, Yves KlettJun 23 '15 at 20:25

• Once you set $n=0$ and the slider is hidden, how do you expect to then alter $n$ if you so wish? – David G. Stork Jun 23 '15 at 16:35
• I've restricted n so that it can only be toggled between 0 and Pi/2. My intention here is to demonstrate the Intermediate Value Theorem, which holds when using f[x, 0], but not when using f[x, Pi/2]. – user170231 Jun 23 '15 at 16:38
• How about apply with Enabled like{{c, \[Pi]}, a, b, Enabled -> n == 0}, {{k, f[a, n], "K"}, f[a, n], f[b, n], Enabled -> n != 0} – Junho Lee Jun 23 '15 at 17:05