clipboard package

Copy and Paste with the LaTeX clipboard package

The clipboard package by Ed­uardo 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.

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:

Once we have compiled the LaTeX file, it looks like any other PDF. I have highlighted the copied text.

LaTeX clipboard

LaTeX code using the clipboard package to store a value in the clipboard.

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.

We see how the LaTeX code pastes what we saved in Einstein into the our PDF. Again, I have highlighted the pasted text.

LaTeX clipboard

LaTeX code using the clipboard package to paste a value from the clipboard.

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.

One thought on “Copy and Paste with the LaTeX clipboard package

Leave a Reply

Your email address will not be published. Required fields are marked *