I am self-studying Royden's Real Analysis; Exercise 58 of Section 9.5, "Compact Metric Spaces", asks:
Let $E$ be a subset of the compact metric space $X$. Show that the subspace $E$ is compact if and only if $E$ is a closed subset of $X$.
The reverse implication is easy: if $E$ is closed, given an open cover $\mathcal{O}$ of $E$, $\mathcal{O} \cup \{X \setminus E\}$ is an open cover of $X$, which, by compactness of $X$, contains a finite subcover $\mathcal{O}'$ of $X$; removing $X \setminus E$ from $\mathcal{O}'$ if necessary, we arrive at a finite subcover of $\mathcal{O}$ of $E$, so $E$ is compact. (In fact, the same argument holds in general for any topological space, not just metric spaces.)
However, I am stumped in trying to prove the forward implication, namely that $E$ being compact in the compact metric space $X$ implies that $E$ is closed in $X$.
This section of the text does contain what it calls the Characterization of Compactness for Metric Spaces, which states:
For a metric space $X$, the following three assertions are equivalent:
(i) $X$ is complete and totally bounded;
(ii) $X$ is compact;
(iii) $X$ is sequentially compact.
I had the thought of using this to say that if $E$ is compact in $X$, then it is complete and totally bounded in $X$, and to show that $E$ being complete implies that $E$ is closed in $X$. However, using the definition of "complete", all we can say is that every Cauchy sequence in $E$ converges in $E$. In contrast to the case of $\mathbb{R}^n$, (according to my understanding) in a general metric space not every convergent sequence is Cauchy, so we cannot use completeness of $E$ to say that $E$ contains all of it limit points in order to prove it to be closed.
I feel as though I am missing something obvious here. Direction would be appreciated.
As I suspected, it was obvious (actually, even worse than that, since I had already proven the necessary lemma for an exercise in the preceding section of the text).
As asked to prove in Exercise 37 of Section 9.4 of the same text, in a metric space, every convergent sequence is Cauchy. Using this, any sequence $\{x_n\}$ in $E$ that converges to some $x$ in $X$ is also Cauchy; since $E$ is compact, it is, by the theorem cited in the original question, complete, and a set is complete if it contains the limits of its Cauchy sequences, so $x \in E$. Therefore, $E$ contains its limit points and is thus closed.
For thoroughness, a proof that every convergent sequence is Cauchy:
Given a sequence $\{x_n\}$ in a metric space $(X,d)$ that converges to $x \in X$, pick $\varepsilon > 0$; by convergence of $\{x_n\}$, $\exists N > 0$ such that $\forall n \geq N$, $d(x_n,x) < \varepsilon/2$. Now, for $n,m \geq N$, the triangle inequality for a metric gives that $d(a_n,a_m)\leq d(a_n, a) + d(a, a_m) < \varepsilon/2 + \varepsilon/2 = \varepsilon$, so $\{x_n\}$ is Cauchy.