I want to insert a symbol (\Box) at the end of the line.
4 Answers
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
amsthmwith itsproofenvironment, mentioned by TH., daleif, and Barbara, orntheoremwith 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.
- 3If this is used as an end of proof marker, then this is a really bad idea. Use the proof environment from the
amsthmpackage or if outside a proof, use\qedfrom the same package.daleif– daleif2011-03-07 11:56:23 +00:00Commented Mar 7, 2011 at 11:56 - @daleif: Having read the source I'm aware that the
amsthmimplementation of\qedis 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– Matthew Leingang2011-03-07 12:55:22 +00:00Commented Mar 7, 2011 at 12:55 - 2@Matthew: simple, what happens if your text is exactly the same length as your text width? Then
\hfillis lost and\Boxis 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\helmosconstruction as is seen in many journal templates. It is a stupid solution and should not be used, especially when a better solution exist.daleif– daleif2011-03-08 13:25:39 +00:00Commented Mar 8, 2011 at 13:25 - 6@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– Matthew Leingang2011-03-08 14:26:21 +00:00Commented Mar 8, 2011 at 14:26
- 1@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.2011-03-08 17:01:36 +00:00Commented Mar 8, 2011 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...
The following works for me:
\\ \parbox{11.9cm}{\hfill} $\Box$ Experiment with the figure in the first { } bracket to get the symbol to appear at the end of your line.
proofenvironment.\marginpar.\hfill\([\qquad]\)is a quick solution obtained from reading the answers below.