From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id qHRLLmCn4l8EFQAA0tVLHw (envelope-from ) for ; Wed, 23 Dec 2020 02:11:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id oJwlKmCn4l80KQAAB5/wlQ (envelope-from ) for ; Wed, 23 Dec 2020 02:11:44 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 089079404C2 for ; Wed, 23 Dec 2020 02:11:44 +0000 (UTC) Received: from localhost ([::1]:46990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1krtcs-0005bg-TZ for larch@yhetil.org; Tue, 22 Dec 2020 21:11:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krtcP-0005bS-QR for emacs-orgmode@gnu.org; Tue, 22 Dec 2020 21:11:14 -0500 Received: from mout02.posteo.de ([185.67.36.66]:34425) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krtcK-0005Js-5e for emacs-orgmode@gnu.org; Tue, 22 Dec 2020 21:11:13 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id BEAE12400FD for ; Wed, 23 Dec 2020 03:11:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1608689462; bh=hnrQAKOpLE8MEMowKkNjg+kZuVu+PsTA05PUvI6pg8s=; h=From:To:Subject:Date:From; b=OqVvK0eqvKPLBlFDrgiX/4ha2SpidvE1PK4HlITR77Ve+ndRHa9Yf/HPM3Nq4wS56 88PLFIFlQqQwsfo6wj/f6Sxl3Y9vyDmlzDgECa7/VLqntOzh2JYgepFHXGqFj04YcR adX0QU4TIQaq7GkLFVDxcuAvXne80XqYQqoN36kszD0xfLcONaE5lPod4FCbKBfCMK +GF6si+R91x6QFMN8qED5tFTWtvj04Tb5zleaGfmHBZ0ZstQietKiFAy3yuRHQ48iP 5LyDLt69ZEwyuCLLeoX3cazbzLzHV4qciacu2cbKNgHvKAeJ7A6jIHq+W41kASkKkI iVj0LKUzWNNtA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4D0xWp1q4hz6tm9 for ; Wed, 23 Dec 2020 03:11:02 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [TIP] Export to LaTeX and HTML with a watermark Date: Wed, 23 Dec 2020 03:11:01 +0100 Message-ID: <87ft3xff0q.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.02 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=OqVvK0eq; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 089079404C2 X-Spam-Score: -2.02 X-Migadu-Scanner: scn1.migadu.com X-TUID: Ad4gwHVQHaNK --=-=-= Content-Type: text/plain Hi, Recently, I needed to export a document to both LaTeX and HTML with a watermark background. I came to write this little function (for LaTeX, the 'draftwatermark' package is used; for html, a bit of CSS. The optional arg `text' is the text of the watermark; by default what is printed is "DRAFT"): #+begin_src org ,#+begin_src emacs-lisp :exports results :results none (defun my-watermark (&optional text) (cond ((org-export-derived-backend-p org-export-current-backend 'latex) (concat "#+LaTeX_Header:\\usepackage" (if text (format "[text=%s]" (replace-regexp-in-string " " "~" text)) "") "{draftwatermark}")) ((org-export-derived-backend-p org-export-current-backend 'html) (concat "@@html:

" (if text (format "%s" text) "DRAFT") "

@@")))) ,#+end_src #+end_src The CSS could be (source: https://stackoverflow.com/questions/68569/text-watermark-on-website-how-to-do-it): #+begin_src org ,#+html_HEAD: #+end_src And then, this replacement macro: #+begin_src org ,#+MACRO: wmark (eval (if (org-string-nw-p $1)(my-watermark $1)(my-watermark))) #+end_src And finally, an example: #+begin_src org {{{wmark(Top secret!)}}} Lorem ipsum dolor sit amet, consectetuer adipiscing elit. accumsan nisl. (...) #+end_src Regards, Juan Manuel --=-=-= Content-Type: text/html --=-=-=--