Ruby, 80 76 bytes
-4 bytes thanks to manatwork
puts"\\";$*[i=0].chars.each_cons 2{|b,c|puts" "*(b==c ?b==?/?i-=1:i+=1:i)+c}
Gets the input as a command line argumentTry it online!
Explanation:
puts "\\" # Output the first backslash
$*[i=0]. # Get the first argument and set i to 0
chars. # Go through every individual character,
each_cons 2 { |b,c| # In pairs to compare easily
#
puts " " * # Decide how many padding spaces to use based on the value
# of i. The expression inside the parenthesis will return
# i but before that, it will increment/decrement i based
# on what the previous character was.
#
( b==c ? # if b == c
b==?/ ? # if b == "/" (Going to the left)
i-=1 # return decremented i
: # else (Going to the right)
i+=1 # return incremented i
: # else
i) + # return i
#
c # Finally, write the second of the characters that we're
} # iterating through.