The clipboard package by Eduardo C. Lourenço de Lima allows you to copy and paste commands across multiple documents. You may think this package seems unnecessary. After all, you can just ctrl-c and ctrl-v to your heart's content as you copy text from one document and paste into as many files you need. But what if you want to ensure that all the changes made in your main document is propagated across all the child documents? This is one area where this package shines.
Using the CTAN clipboard package
Copying into the Clipboard
The first thing you need to do is set up your main file, in this case Book.tex, to copy the things you need into a new clipboard. First, you need to name the clipbaord you are pasting to. We are calling the clipboard myclipboard, and we are going to copy a quote by Albert Eninstein (because why not?) into that clipboard.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
\documentclass{article} \usepackage{lipsum} \usepackage{clipboard} \newclipboard{myclipboard} \begin{document} \lipsum[1] \Copy{Einstein}{We cannot solve our problems with the same thinking we used when we created them. \\ Albert Einstein} \lipsum[2] \end{document} |
Once we do this, we compile and voila. Compiling is an important step as it creates a .cpy file where the saved clipboard information is stored as a LaTeX macro. This can then be used by the package to find the necessary information to paste into other documents. A peek into the myclipboard.cpy looks something like:
1 2 3 |
\clipboard {Einstein}{We cannot solve our problems with the same thinking we used when we created them. \\ Albert Einstein} |
Once we have compiled the LaTeX file, it looks like any other PDF. I have highlighted the copied text.
Pasting from the Clipboard
Now that we have created a clipboard and copied some text into it, we can now paste that text into a new document. Our clipboard was called myclipboard and we will be copying the information stored in Einstein into our document.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
\documentclass[preview]{standalone} \usepackage{color, soul} \usepackage{lipsum} \usepackage{clipboard} \openclipboard{myclipboard} \begin{document} \lipsum[3] \begin{quote} \Paste{Einstein} \end{quote} \lipsum[4] \end{document} |
We see how the LaTeX code pastes what we saved in Einstein into the our PDF. Again, I have highlighted the pasted text.
Looks pretty simple, doesn't it? Well, it is.
Uses for the clipboard package
There may not seem like there is much you can do with this package when a simple copy and paste will do but I argue differently. If your manuscripts contain a lot of quotations that you use frequently, you can create an initial LaTeX file that assembles all these quotes and saves them to the clipboard. This makes proofing a page of quotes relatively easy. These quotes can then be pasted into your manuscript. Of course, there are some disadvantages. All the LaTeX files need to be in the same folder, including the new clipboard file. Other than that, this is a pretty fun package to have in your LaTeX toolbox.