summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/clipboard/clipboard.tex
blob: c758527baf25f82a569114da4b456558193a22f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
% Copyright (C) 2013 Eduardo C. Lourenço de Lima
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any later
% version.  The latest version of this license is in
%
%   http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
\documentclass{ltxdoc}

\newcommand\fileversion  {0.3}
\newcommand\filedate     {May 18, 2016}

\newenvironment{Description}
 {\par\medskip\noindent\ignorespaces}{}

\newenvironment{synopsis}
 {\begin{list}{}{\setlength\parsep{0pt}\setlength\itemsep{0pt}}}
 {\end{list}}

\title  {The \textsf{clipboard} package\thanks{This document corresponds to \textsf{clipboard}~\fileversion, dated~\filedate.}}
\author {Eduardo C. Louren\c{c}o de Lima\\\texttt{elourenco@phi.pro.br}}
\date   {\filedate}

                                \begin{document}
                                   \maketitle

                            \section*{Introduction}

The |clipboard| package provides a basic framework for copying and pasting content within a single document or across multiple documents.

\begin{synopsis}
\item |\newclipboard | \marg{basename}
\item |\openclipboard| \marg{basename}\medskip
\item |\Copy |         \marg{key} \marg{content}
\item |\Paste|         \marg{key}
\end{synopsis}

                                \section{Usage}

\begin{Description}
\DescribeMacro{\newclipboard}
The first step is to create a clipboard.
\begin{synopsis}
\item |\newclipboard| \marg{basename}
\end{synopsis}
\end{Description}

\begin{Description}
\DescribeMacro{\Copy}
The command |\Copy| copies a \meta{content} identified as \meta{key} to the clipboard.\footnote
{Lowercase \texttt{\char92 copy} is already defined in {\TeX}.}
\begin{synopsis}
\item |\Copy| \marg{key} \marg{content}
\end{synopsis}
\end{Description}

\begin{Description}
\DescribeMacro{\Paste}
And the command |\Paste| pastes the content identified by \meta{key} somewhere else in the same or another document.
See below.
\begin{synopsis}
\item |\Paste| \marg{key}
\end{synopsis}
\end{Description}

\begin{Description}
\DescribeMacro{\openclipboard}
Finally, |\openclipboard| makes the same content available across multiple documents.
For instance, you can paste content from |doc1.tex| into |doc2.tex|.
Make sure to use the same \meta{basename} in both documents.
\begin{synopsis}
\item |\openclipboard| \marg{basename}
\end{synopsis}
\end{Description}

                               \section{Example}

This is how to copy and paste text from |book.tex| into |article.tex|:\bigskip

\noindent |book.tex|:
\begin{verbatim}
    \documentclass{book}
    \usepackage{clipboard}
    \newclipboard{myclipboard}
    \begin{document}
        \Copy{dolorem ipsum}{Nor again is there anyone who
        loves or pursues or desires to obtain pain of itself},
        because it is pain, but occasionally circumstances occur
        in which toil and pain can procure him some great pleasure.
    \end{document}
\end{verbatim}

\noindent |article.tex|:
\begin{verbatim}
    \documentclass{article}
    \usepackage{clipboard}
    \openclipboard{myclipboard}
    \begin{document}
    According to Cicero,
        \begin{quote}
        \Paste{dolorem ipsum}
        \end{quote}
    \end{document}
\end{verbatim}

\noindent\textbf{Note:} Because content from |book.tex| is being copied and pasted into |article.tex|, you must run |latex book.tex| before running |latex article.tex|.

                                 \end{document}