As the title says I need to define a QED symbol automatically (preferable a colorbox) at the end of my custom newtheorem.
Any suggestions would be appreciated.
Advice: don't do it. The placing of the QED symbol depends in a non-straightforward way on the contents of your text in your environment. For instance, Andrea's code will fail if your theorem ends with display math. You will probably need to place it by hand sometimes, and you are less likely to overlook things if you always do this.
Much better would be to have an environment that complains if the QED symbol has not been placed. You can do this by defining a qedused flag, say by \newififqedused, that is unset when you enter the environment (define a wrapper using \newenvironment as Andrea said), set in a wrapper around the QED symbol, and tested when you exit the environment. If the flag is still unset on exit, issue a \PackageWarning or \PackageError.
If you really want to try to get a qed environment that tries hard to do the right thing, regardless of what is in the environment, you'll need to look into the contents of \lastbox to try to determine where the QED symbol should go. If it is an hbox, you are fine, just place the QED as per Andreas' solution. If it is an mbox, then I think making an hbox containing this mbox followed by the QED symbol should work - I'm not sure, I don't usually mess about with the typesetting of maths.
If it is a vbox, you need to look inside the structure of the vbox to find where it should go, which sounds hard - I can't think how to do that in pure Tex. In Luatex, I think that Hans Hagen's trick in The LuaTEX way: \framed might be adapted for this.
I'm not sure what you mean. If you use the package amsthm you have the command \qed to put a QED wherever you want.
You can customize the \qed by changing the command \qedsymbol. So you would do something like
\usepackage{amsthm}
\renewcommand{\qedsymbol}{$\heartsuit$}
\newtheorem{thm}{Theorem}
\newenvironment{\mythm}{\begin{\thm}}{\qed \end{thm}}
...
\begin{mythm}
blah
\end{mythm}
This if you want the QED symbol to be the same that appears in proofs. If not you can do simply
\newtheorem{thm}{Theorem}
\newenvironment{\mythm}{\begin{\thm}}{\hfill $\heartsuit$ \end{thm}}
...
\begin{mythm}
blah
\end{mythm}
Of course you can change \heartsuit with whatever you want.
An alternative is to use the ntheorem package with the options thmarks. that is \usepackage[thmarks]{ntheorem}.
You can then play with the settings to get what you want exactly...
Related
I work on a huge script in \latex.
I want to be able to compile each of the chapters as stand-alone, because it is easier for hacking sessions with Latex.
On the other hand, I would like to maintain a document which encompasses the whole script so far written.
I do not know how to maintain both these documents without permanently annoying overhead, as a tex-file can either be written stand-alone or to be included.
It would be great help to have something a Latex-preprocessor available that is capable of C-like #define and #ifdef-#else-#endif statements. This would facilitate writing to a great extent. Do you know whether something like this exists in latex, or how can you do something equivalent? Google hasn't supplied me with a satisfying answer to this.
EDIT:
Some remarks in order to avoid misunderstandings: I am aware of the very simple built-in TEX-preprocessor, but these commands don't work properly as I expected. Hence a reference to these will not help me out.
The chapters in my script shall look something like this (Pseudo-Code)
IF being_just_included defined
%No header here, and document has already begun
ELSE
\input{common_header.tex} %Header things all my documents use
\begin{document}
ENDIF
%%% Lots of stuff
IF being_just_included defined
%Nothing to do here
ELSE
\end{document}
END IF
In contrast, my complete script source file should look like this
\input{common_header.tex}
DEFINE being_just_included
\begin{document}
\input{preamble.tex}
\input{first_chapter.tex}
\input{second_chapter.tex}
\input{third_chapter.tex}
\end{document}
Could you post a code which performs something like this?
Thank you very much for this package and the hint to the forum.
After some time I've figured out there exists a tex preprocessor, which is similar to the CPP. Maybe not well-engineered, but it serves my purpose quite well.
The magic lines are:
\def\justbeingincluded{justbeingincluded}
\ifx\justbeingincluded\undefined
\fi
to be used appropiatly within the respective source files.
One way of doing this is to use the standalone package, intended for this specific purpose.
You may also care to browse through, and perhaps join, TeX and Friends.
I would like to globally prevent LaTeX from hyphenating 'Objective-C'. I am aware of the \hyphenation command, but I don't see how I can make use of it. If I pass 'Objective-C' to this command, the dash will be treated as a hint to hyphenate the word there.
One solution I found is wrapping Objective-C into an mbox each time I use it. However, the document I am writing contains this name a lot, and wrapping it into an mbox each time is ugly (as is defining a command and using this over and over again in the source code).
Why is defining a new command ugly? It's how \LaTeX\ defines itself.
\def\ObjectiveC{\mbox{Objective-C}}
Use \nobreakdash. That's what LyX produces when I insert a nonbreakingdash and convert it to tex.
As suggested here, you could define a command like this:
\newcommand\dash{\nobreakdash-\hspace{0pt}}
and use it like this
Consider the $n$\dash dimensional manifold ...
Also, you could use the babel package and use "~ as a protected hyphen. I'm not sure if using babel is advisable when writing in english, though.
I'm new to latex, but it seems you can temporarily redefine some commands? The problem I have is that normally the citation is (SMITH, 2000). But at times, I'd like to have Smith (2000) instead. Anyway I can temporarily redefine it, then use the standard version again after that "block" of code?
Enclose the local definition in braces ({}).
\newcommand\foo{FOO!}
\foo
{\renewcommand\foo{BAR?}\foo\foo}
\foo
This will generate something like:
FOO!BAR?BAR? FOO!
This can be done inside macro definitions, too - just make sure you add the extra braces:
\newcommand\newfoo{{\renewcommand\foo{BAR?}\foo}}
Hope this helps.
You should already have \citep and \citet commands that should do what you want, there's no reason to redefine the macros yourself.
In my english thesis latex file, how to mention the following non English words: François, École Fédérale?
Thanks and regards!
The traditional way is to use the accent-adding macros:
Fran\c{c}ois
\'Ecole F\'ed\'erale
(You can also write Fran\c{}cois or Fran\c cois; the \c macro uses no parameter; the braces or space are just a trick to allow LaTeX to see the proper macro name.)
Otherwise, try this:
\usepackage[utf8]{inputenc}
and type the accents directly, with UTF-8 encoding.
There are a host of more-or-less subtle issues with fonts and hyphenation.
If you don't go the UTF8 inputenc route, and yet find yourself writing a lot of these names, I'd suggest defining macros for them. At the simplest, you can say \newcommand\Francois{Fran\c cois} but then you need to be sure to use it as such: \Francois{} so that any spaces afterwards don't get gobbled.
On the other hand, the following technique works pretty well too (though I can't take credit for inventing it - I saw it originally in a short talk at BachoTeX 2009 by Philip Taylor):
\makeatletter
\let\latex#less<
\catcode`<13
\def<{\ifmmode\latex#less\else\expandafter\find#name\fi}
\def\find#name#1>{\#nameuse{name.#1}}
\def\DefineName#1#2{\#namedef{name.#1}{#2}}
\makeatother
Now you can define special names using, e.g.
\DefineName{Francois}{Fran\c cois}
\DefineName{Ecole Federale}{\'Ecole F\'ed\'erale}
and later on you can use them in text with
I ran into <Francois> at the <Ecole Federale> the other day.
You can make your tags (the plain ASCII versions) be whatever you want - they don't have to actually be related to the properly accented names.
EDIT: in response to the issue that misspelled names don't produce errors, you can change the definition of \find#name to
\def\find#name#1>{\ifcsname name.#1\endcsname
\#nameuse{name.#1}%
\else
\#latex#warning{Undefined name #1}%
\fi}
Note that \#latex#warning{...} can be changed to \#latex#error{...}\#eha and it will complain more forcefully. Or if you want to pretend to be (or actually be) a package you can use \Package(Warning|Error){<package name>} in place of \#latex#(warning|error) and it won't pretend to be a built-in LaTeX error anymore.
I need a way to add text comments in "Word style" to a Latex document. I don't mean to comment the source code of the document. What I want is a way to add corrections, suggestions, etc. to the document, so that they don't interrupt the text flow, but that would still make it easy for everyone to know, which part of the sentence they are related to. They should also "disappear" when compiling the document for printing.
At first, I thought about writing a new command, that would just forward the input to \marginpar{}, and when compiling for printing would just make the definition empty. The problem is you have no guarantee where the comments will appear and you will not be able to distinguish them from the other marginpars.
Any idea?
todonotes is another package that makes nice looking callouts. You can see a number of examples in the documentation.
Since LaTeX is a text format, if you want to show someone the differences in a way that they can use them (and cherry pick from them) use the standard diff tool (e.g., diff -u orig.tex new.tex > docdiffs). This is the best way to annotate something like LaTeX documents, and can be easily used by anyone involved in the production of a document from LaTeX sources. You can then use standard LaTeX comments in your patch to explain the changes, and they can be very easily integrated. If the document lives in a version control system of some sort, just use the VCS to generate a patch file that can be reviewed.
I have used changes.sty, which gives basic change colouring:
\added{new text}
\deleted{old text}
\replaced{new text}{old text}
All of these take an optional parameter with the initials of the author who did this change. This results in different colours used, and these initials are displayed superscripted after the changed text.
\replaced[MI]{new text}{old text}
You can hide the change marks by giving the option final to the changes package.
This is very basic, and comments are not supported, but it might help.
My little home-rolled "fixme" tool uses \marginpar where possible and goes inline in places (like captions) where that is hard to arrange. This works out because I don't often use margin paragraphs for other things. This does mean you can't finalize the layout until everything is fixed, but I don't feel much pain from that...
Other than that I heartily agree with Michael about using standard tools and version control.
See also:
Tips for collaboratively editing a LaTeX document (which addresses you main question...)
https://stackoverflow.com/questions/193298/best-practices-in-latex
and a self-plug:
How do I get Emacs to fill sentences, but not paragraphs?
You could also try the trackchanges package.
You can use the changebar package to highlight areas of text that have been affected.
If you don't want to do the markup manually (which can be tedious and interrupt the flow of editing) the neat latexdiff utility will take a diff of your document and produce a version of it with markup added to visually display the changes between the two versions in the typeset output.
This would be my preferred solution, although I haven't tested it out on large, multi-file documents.
The best package I know is Easy Review that provides the commenting functionality into LaTeX environment. For example, you can use the following simple commands such as \add{NEW TEXT}, \remove{OLD TEXT}, \replace{OLD TEXT}{NEW TEXT}, \comment{TEXT}{COMMENT}, \highlight{TEXT}, and \alert{TEXT}.
Some examples can be found here.
The todonotes package looks great, but if that proves too cumbersome to use, a simple solution is just to use footnotes (e.g. in red to separate them from regular footnotes).
Package trackchanges.sty works exactly the way changes.sty. See #Svante's reply.
It has easy to remember commands and you can change how edits will appear after compiling the document. You can also hide the edits for printing.