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
amsthm
with itsproof
environment, mentioned by TH., daleif, and Barbara, orntheorem
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.
-
3If 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.– daleifMar 7, 2011 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? Mar 7, 2011 at 12:55 -
2@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.– daleifMar 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. 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.– Stefan Kottwitz ♦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.
proof
environment.\marginpar
.\hfill\([\qquad]\)
is a quick solution obtained from reading the answers below.