From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id ECbAIloe6l+rRgAA0tVLHw (envelope-from ) for ; Mon, 28 Dec 2020 18:05:14 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id +AOLHloe6l/VCQAAbx9fmQ (envelope-from ) for ; Mon, 28 Dec 2020 18:05:14 +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 81017940438 for ; Mon, 28 Dec 2020 18:05:13 +0000 (UTC) Received: from localhost ([::1]:60242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktwtM-0007wG-9W for larch@yhetil.org; Mon, 28 Dec 2020 13:05:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktws8-0007Tv-H5 for emacs-orgmode@gnu.org; Mon, 28 Dec 2020 13:03:58 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]:34510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktws5-0005RQ-2f for emacs-orgmode@gnu.org; Mon, 28 Dec 2020 13:03:56 -0500 Received: by mail-qt1-x82c.google.com with SMTP id 7so7428340qtp.1 for ; Mon, 28 Dec 2020 10:03:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:references:user-agent:from:to:cc:subject:in-reply-to :message-id:date:mime-version:content-transfer-encoding; bh=lPG3ougbhKRePRHd6fF8EAtli3ihbvQBHArIeQxoOes=; b=flRpcJQdkzofNxSR9pc0wQc2eeqO8Lq/Gu/GY7eEjeft0fW02py4njmnXPRhoC+DQp NJvl24hsYdmWCBjIWmeMD14h330swAcp64ADhSypKiOU2Pp+ofJ4obbJpLtVFP4g4wc6 b6kyiB3unfwsPMcjARpcMR18MfVeE4tRDgsCLxDBA/uJLpYdXnSbrtfy6AK43JvSuwvd jHC+HCwLNAHzCkxO4TcpETyFTDdlqWPBuJ3O7yAvVlugSnA+J69Gz4tIDq9aSqzZHki4 yofWOFKSmgp9knOqnr7DoHPpaaR4JZIDYYWwsgksDxe5UvvuRDxCbJwcpo63H525yEqz rs4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version:content-transfer-encoding; bh=lPG3ougbhKRePRHd6fF8EAtli3ihbvQBHArIeQxoOes=; b=FYr8qaldM1vxcWyylw6wUrA3+BdZJaB+GT749tzgUMT/vfJxYULf+48QO3GGx6SSlM eFV+JVFmJYxFGpP6cgEkgBRrUzgchs/uo/4/QNrGS+HpKG9pz/FSGOjumarGeK0sVpSS 6fNDaY8fiWFt0bcx7ufcyO6asSbGfztHo7gllV0zeec+bbk9XJ3crAZxZ/jMD92aE9B+ vbTVkkMuZHAoejKehnS2qfa82opl2vcUQ7o5CbH0anX340cAL4qVafrdNbPtu5tkdBhx cKKlf/Dbl6yFOijiRyclj/HsU/f2JM/J9IHlcjnaSZdpFB4O4pRqzYkeEWHWVlUSJ1hf Jw5w== X-Gm-Message-State: AOAM5334jwGjmLgELV1CSOKGojxzvqBJTWF4wbE4k/qupA6Bg9wSyZ7J TuciZ7OSNlCOYwbeY4dYUQBpJb4HnX2Wdw== X-Google-Smtp-Source: ABdhPJxnwW8+ClL82vA8/Xga9MmBMxNh8PXfnqijQi2lUFXJN50MKNOSew2Fkg4/w6mRpqsglnHCDw== X-Received: by 2002:ac8:6651:: with SMTP id j17mr45679113qtp.176.1609178630007; Mon, 28 Dec 2020 10:03:50 -0800 (PST) Received: from Johns-iMac.local (full-vpn-1.nat.cmu.net. [128.2.149.108]) by smtp.gmail.com with ESMTPSA id f22sm24374060qkl.65.2020.12.28.10.03.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Dec 2020 10:03:49 -0800 (PST) References: <87mty1an66.fsf@posteo.net> User-agent: mu4e 1.4.13; emacs 27.1 From: John Kitchin To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= Subject: Re: [tip] Export subfigures to LaTeX (and HTML) In-reply-to: <87mty1an66.fsf@posteo.net> Message-ID: Date: Mon, 28 Dec 2020 13:03:48 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=johnrkitchin@gmail.com; helo=mail-qt1-x82c.google.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URI_DOTEDU=1.999 autolearn=no 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: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.22 Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=gmail.com header.s=20161025 header.b=flRpcJQd; dmarc=fail reason="SPF not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); 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: 81017940438 X-Spam-Score: -1.22 X-Migadu-Scanner: scn0.migadu.com X-TUID: Lgy5TaKbG69O This is an interesting use of links, in particular extending the information in the description. You might look at this http://kitchingroup.cheme.cmu.edu/blog/2015/02/05/Extending-the-org-mode-li= nk-syntax-with-attributes/ for another way to do that. Check out this alternative approach all together that also uses a special block. http://kitchingroup.cheme.cmu.edu/blog/2016/01/17/Side-by-side-figures-in-o= rg-mode-for-different-export-outputs/ I don't use either of these today, and they are old so who knows if they still work, but they have some fun ideas in them. Juan Manuel Mac=C3=ADas writes: > Hi, > > I have come up with a way to export subfigures to LaTeX (with the subfigu= re package) by > defining a new link type. The 'subcaption' of the subfigure would be the = description of > the link. If we want to add parameters such as width, scale, etc., we can= put them next > between the marks '>( ... )' > > The code: > > #+begin_src emacs-lisp > (org-link-set-parameters > "subfig" > :follow (lambda (file) (find-file file)) > :face '(:foreground "chocolate" :weight bold :underline t) > :display 'full > :export (lambda (file desc backend) > (when (eq backend 'latex) > (if (string-match ">(\\(.+\\))" desc) > (concat "\\subfigure[" (replace-regexp-in-string "\s+>(.+)" "" desc)= "]" > "{\\includegraphics" > "[" > (match-string 1 desc) > "]" > "{" > file > "}}") > (format "\\subfigure[%s]{\\includegraphics{%s}}" desc file))))) > #+end_src > > Example: > > #+begin_src org > ,#+CAPTION: Lorem impsum dolor > ,#+ATTR_LaTeX: :options \centering > ,#+begin_figure > [[subfig:img1.jpg][Caption of img1 >(width=3D.3\textwidth)]] > > [[subfig:img2.jpg][Caption of img2 >(width=3D.3\textwidth)]] > > [[subfig:img3.jpg][Caption of img3 >(width=3D.6\textwidth)]] > ,#+end_figure > #+end_src > > Results: > > #+begin_src latex > \begin{figure}\centering > \subfigure[Caption of img1]{\includegraphics[width=3D.3\textwidth]{im= g1.jpg}} > > \subfigure[Caption of img2]{\includegraphics[width=3D.3\textwidth]{im= g2.jpg}} > > \subfigure[Caption of img3]{\includegraphics[width=3D.6\textwidth]{im= g3.jpg}} > \caption{Lorem impsum dolor} > \end{figure} > #+end_src > > If we want to export to HTML it would be something more tricky. In this c= ase, the export > function could be like this (a width parameter would be enclosed between = >{ ... }): > > #+begin_src emacs-lisp > (lambda (file desc backend) > (cond > ((eq backend 'latex) > (if (string-match ">(\\(.+\\))" desc) > (concat "\\subfigure[" (replace-regexp-in-string "\s*>.+" "" desc) "]"= "{\\includegraphics" "[" (match-string 1 desc) "]" "{" file "}}") > (format "\\subfigure[%s]{\\includegraphics{%s}}" (replace-regexp-in-stri= ng "\s*>.+" "" desc) file))) > ((eq backend 'html) > (if (string-match ">{\\(.+\\)}" desc) > (concat "3D\"" (match-string 1 desc) > "\"" > "/>
" > (replace-regexp-in-string "\s*>.+" "" desc) > "") > (format "3D\"%s\"/
%s" > file file > (replace-regexp-in-string "\s*>.+" "" desc)))))) > #+end_src > > Example: > > #+begin_src org > ,#+CAPTION: Lorem impsum dolor > ,#+ATTR_LaTeX: :options \centering > ,#+begin_figure > @@html:
@@ > > [[subfig:img1.jpg][Caption of img1 >(width=3D.3\textwidth) >{300px}]] > > [[subfig:img2.jpg][Caption of img2 >(width=3D.3\textwidth) >{300px}]] > > @@html:

@@ > > [[subfig:img3.jpg][Caption of img3 >(width=3D.6\textwidth) >{600px}]] > > @@html:

Lorem ipsum dolor
@@ > ,#+end_figure > #+end_src > > As you can see, it is not the panacea, and you have to apply some direct = format... > > Happy holidays > > Juan Manuel -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu