# Insert a symbol at the end of line

I want to insert a symbol (\Box) at the end of the line.

• If you're doing this to denote the end of a proof, consider using the proof environment. – TH. Mar 7 '11 at 6:50
• it would help us to answer better if you could give us a bit more detail of what you're trying to achieve. For example, one possible (though unlikely) answer would be to use \marginpar. – Brent.Longborough Mar 7 '11 at 9:52
• To offer another motivation: At the end of the question body of a multiple choice question, I wanted to insert a pair of square brackets where students could write their answer. \hfill$$[\qquad]$$ is a quick solution obtained from reading the answers below. – Frenzy Li Jul 29 '18 at 12:37

Simply use \hfill before \Box:

\documentclass{article}
\usepackage{latexsym}
\begin{document}
Text\hfill$$\Box$$
\end{document}


Edit: To clarify a bit regarding the comments: this simple command is intended as an answer to the simple question, how to insert a symbol at the end of the line.

The mentioned \Box may lead to the assumption, that the question might be about a proof. The highly upvoted comment of TH. still awaits an answer by the questioner. In the case of a proof it's strongly recommended to use

• amsthm with its proof environment, mentioned by TH., daleif, and Barbara, or

• ntheorem with proper placement of such endmarks even after a displayed math environment or a list.

The answers to Theorem packages: which to use, which conflict? can help in deciding which to use.

• If this is used as an end of proof marker, then this is a really bad idea. Use the proof environment from the amsthm package or if outside a proof, use \qed from the same package. – daleif Mar 7 '11 at 11:56
• @daleif: Having read the source I'm aware that the amsthm implementation of \qed is much more complicated than a simple \hfill. So I guess when you say "bad", you mean "prone to unexpected behavior", right? Could you elaborate on that? – Matthew Leingang Mar 7 '11 at 12:55
• @Matthew: simple, what happens if your text is exactly the same length as your text width? Then \hfill is lost and \Box is at the start of the next line, or you may even end up with the box as being the first thing on the next page. I usually call it the \helmos construction as is seen in many journal templates. It is a stupid solution and should not be used, especially when a better solution exist. – daleif Mar 8 '11 at 13:25
• @daleif: That explains it very well. But I don't think it's necessary to call others' answers stupid. Obviously Stefan's a mod and a big boy so he can take the criticism but we try to keep things supportive here. Each answer is voted on and usually the best ones rise to the top. – Matthew Leingang Mar 8 '11 at 14:26
• @Matthew @daleif @Hendrik @Brent: supportive and critical comments are welcome. :-) I'm just wondering a bit about so much speculation and talk, while I would wait for the reaction to TH.'s comment. If anybody likes it to remove his comment here, feel free :) Code and tipps in comments often make a good answer on its own. I will remove mine which I'm just writing. – Stefan Kottwitz Mar 8 '11 at 17:01

here is a comment repeated from question 3799 which asked about putting "boxes" (or other symbols) at the ends of either text lines or displayed equations. although the direct relevance is to amsthm, the approach should be workable in other contexts as well.

it was not originally recognized that "boxes" would be wanted at the end of anything other than proofs, but over the past year there have been numerous requests for this facility. a wholesale upgrade of this feature, including adding the ability to mark non-proofs, is on our to-do list. in the meantime, see “Theorems in AMS-LaTeX” in the ams author faq. it contains a link to an example file that demonstrates various tactics that can be used with amsthm to get different symbols and put them in different locations.

A related issue concerns inserting a symbol at the end of a displayed equation. E.g., if one has a specific symbol for the end of a remark or definition, and the remark or definition ends with a displayed equation. (Placement of the qed symbol at the end of a proof with a displayed equation is easy---simply add the command \qedhere at the end of the equation.) One option is to do something like

\begin{flalign*}
&& <equation> && <symbol>
\end{flalign*}


Just thought I'ld mention this one here...