From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id qKxsIOcSW2AoAwAA0tVLHw (envelope-from ) for ; Wed, 24 Mar 2021 10:22:31 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id qOAoHOcSW2BWIAAAbx9fmQ (envelope-from ) for ; Wed, 24 Mar 2021 10:22:31 +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 ADBE029473 for ; Wed, 24 Mar 2021 11:22:30 +0100 (CET) Received: from localhost ([::1]:56228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lP0ei-0004Zp-D8 for larch@yhetil.org; Wed, 24 Mar 2021 06:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP0dy-0004Zd-KC for emacs-orgmode@gnu.org; Wed, 24 Mar 2021 06:21:42 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]:37770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lP0dw-0003nK-M0 for emacs-orgmode@gnu.org; Wed, 24 Mar 2021 06:21:42 -0400 Received: by mail-lj1-x22a.google.com with SMTP id r20so29520032ljk.4 for ; Wed, 24 Mar 2021 03:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:date:from:to:cc:subject:in-reply-to:references :user-agent:message-id; bh=qq8x2jJ1vYmfIeQBsq2QToBZmDVspRPOaNn98ioc/dA=; b=Sy87AmyKKHbyFD7W68HZEGQSNN8h8KePLCocrruhrpuLlECV2IPErqvrooYJ+n1xL/ seK6Zt1dxvFJ+I83ozrvoY0GcEcb03zvbH2zICCq4E38ozc+uZr45o9qSlTOvTDGImjQ K4TVyJYtAgJa7hxUcAzhpVIvUcnt/XFg/UEPiSa4xMj1AFPT0N4Z1E8iD926ChQE/X/F Qh6OZTdTwKK7ISPbllsF+y7cdjgFLpIEgy1OUM3qgsVK9Q6GGmbpV1HEu8QVOBAVKr7W hRFzIzumBME0dU71qpKImJHIz2wGCHgYT8NnjX4EQXpcNrOWqkkFYGeBNbt/1v+1HRTs rxMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:from:to:cc:subject:in-reply-to :references:user-agent:message-id; bh=qq8x2jJ1vYmfIeQBsq2QToBZmDVspRPOaNn98ioc/dA=; b=QggXB9alNDxLpT5JfFLMjjw+/BXOgKr95OnH8gtRmhYKyzPyQsYMOMlfDDpdNAj4b8 2ZVpLZEub3u5eH5R+GZdcbktVFdCn0bUDaUSwvXehCJCUFZys1VdcR0v/XHh/5lIaNhf gZWf5vM51HtOgIHu1IGtILLYsfbCkEK0C7hzy8meUg/vI4ud6D1Z5zGUjH6wMrA+ja9M bOYZnQzmwPABj7lzwJb36o6IzgHqfTPZY0EnYf5peIVlrl4eGyu32PAkzXqBYeSrB46Z 0QCXRMjJ4aTwv0hq5UJJN/0vL6jAcojcVWfQyk1Vg/gmKdhXFNOjrCQLJkr2WSAAf6fk YkNw== X-Gm-Message-State: AOAM533zxzvlm+Nv6nSOwSvrJo1mjKVVIfWOo/UIev4TXnW5dEz36VIr p/sRl5OnGoSq3USwMaF3Cbg= X-Google-Smtp-Source: ABdhPJzRPsqhlQ/vkPoMjnyKRKXtR1TNIltHetBp25DNSPnlGRi8mGMjq5OTzYvdpOWUnp4kPJaJwA== X-Received: by 2002:a2e:8503:: with SMTP id j3mr1666071lji.272.1616581298302; Wed, 24 Mar 2021 03:21:38 -0700 (PDT) Received: from m.g.s.chen.ac (cm-84.214.37.174.getinternet.no. [84.214.37.174]) by smtp.gmail.com with ESMTPSA id h17sm185689lfc.289.2021.03.24.03.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 03:21:37 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 24 Mar 2021 10:26:15 +0000 From: =?UTF-8?Q?Xianwen_Chen_=28=E9=99=88=E8=B4=A4=E6=96=87=29?= To: =?UTF-8?Q?Christine_K=C3=B6hn?= Subject: Re: Exam LaTeX class In-Reply-To: <87pmzvo3i4.fsf@chark.eu> References: <87pmzvo3i4.fsf@chark.eu> User-Agent: Roundcube Webmail/1.4.10 Message-ID: <43d0c2349e6a4345f7f100b13244c0a6@gmail.com> X-Sender: xianwen.chen@gmail.com Content-Type: multipart/alternative; boundary="=_95156a4bee95e9ee70ab85566792cf32" Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=xianwen.chen@gmail.com; helo=mail-lj1-x22a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616581351; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=qq8x2jJ1vYmfIeQBsq2QToBZmDVspRPOaNn98ioc/dA=; b=sULreafKblaapOWyOY63+kifE3ffNxg2E72gIuyylVf1saOtaLNsKiWyMWFrLGIScqyVKS SKJnHmCzOfrZe4KqzEeehmEL/SszhrrAs37Y5fQJZvFjd0UpyTpjHzB2mQgMRUB0cEtdpi d8UjripCyaTDyY9JmKDh9RHG9DDfY9+ZT6eKg9r2Mo6xdUi0r5+EM9WLYns4lsqeFLJsKW iux3uhuqF4GBDyiQ4FJAY5jGNUPaAwe6hBAaMLuK7BEddi6gvV83K4WlHeSrs6tO7m7vXc FM1VUbJJFBN5doFqu7dTw6K+YW8Qs37DLGcD2bWHq86OoABC95gIF05Ry4xYJQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616581351; a=rsa-sha256; cv=none; b=Cl4bk3OeQqsJut/H7Yho6oY9Utgw720exhS1mZBOOa1miOJA9xzgCsp2mYYlx7r9a62UCy G/ouK4ozJiLXCyf2KtUPqcs+VMF5zs2R/UN4D/PJy+3Agrircy/5sqrkboDK41qIqRCmDK kYSTJKkuNpEq7dYWBhIi4qKtB6gBie9L3Rj958nXwkX9POcF88fntan6ASedsgNMtHBEfO QtTJm3juf6MDBaeNEfTz6fJlR7FSqGMPSMyx0dE0DZorA6p2x8RGY8t2+R4Ti4BlQCbZYU cd6+62edSoCcj6iTNjtfB5JgxKG/hRQgxjU0g47UXDNHjohlf8jIKI3Wj/vqdg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Sy87AmyK; dmarc=pass (policy=none) header.from=gmail.com; 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-Spam-Score: -3.12 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=Sy87AmyK; dmarc=pass (policy=none) header.from=gmail.com; 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: ADBE029473 X-Spam-Score: -3.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: JcsYPy4bh+Gu --=_95156a4bee95e9ee70ab85566792cf32 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8; format=flowed Dear Christine (and CC list), Thank you! On 2021-03-19 10:13, Christine Köhn wrote: > Here is one way to do the latex part. You could pass a jobname to > latex. > > I have this > > \IfEndWith*{\jobname}{withsolution}{% > \usepackage{todonotes} > \printanswers > }{\usepackage[disable]{todonotes}} > > in a myexam.sty file to switch between modes (with or without solutions > and todo notes) and use it in the latex file with > > \usepackage{myexam} > > You could add your own latex class to org-latex-classes and add this > line there. > > The jobname has to be passed to latex with something like -jobname > withsolution if you want it to be with solutions. I use a Makefile for > this purpose which calls latexmk > > latexmk -pdf -pdflatex="pdflatex --interaction=errorstopmode" -use-make > > and adds -jobname=$(basename $@) if asked to create a pdf ending with > withsolution.pdf. I can send you the Makefile if you're interested. That's very interesting way to solve the problem using LaTeX. Thank you for sharing this. At the moment I'm leaning more towards solving it using emacs lisp. > To use the jobname from within orgmode, you'll have to change > org-latex-pdf-process to use the jobname if needed. I think one way to > achieve this is to add a new export backend which is derived from latex > (see org-export-define-derived-backend) and which sets > org-latex-pdf-process accordingly (and resets it afterwards). Thank you again. I'm thinking of a function like following. I'm using comments to express the programming detail that I don't know how to do yet. (deffun org-latex-export-to-pdf-exam () (interactive) # do some emacs lisp to add \printanswers to the end of org document header, i.e., adding a line of #+LATEX_HEADER: \printanswers (org-latex-export-to-pdf) # do some emacs lips to move the foo.pdf to foo-with_solutions.pdf # do some emacs lisp to add \noprintanswers to the end of org document header, i.e., removing the line of #+LATEX_HEADER: \printanswers and adding a line of #+LATEX_HEADER: \noprintanswers (org-latex-export-to-pdf) # remove the line of #+LATEX_HEADER: \noprintanswers ) I don't know enough emacs lisp to fill in the details here for now. However, I think this would be a way to do it within emacs. So each time I call org-latex-export-to-pdf-exam, it would export two PDF files, one with solutions and one without. What do you think? Yours sincerely, Xianwen --=_95156a4bee95e9ee70ab85566792cf32 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

Dear Christine (and CC list),

Thank you!

 


On 2021-03-19 10:13, Christine Köhn wrote:

Here is one way to do the latex part. You could pass a jobname to latex= =2E

I have this

\IfEndWith*{\jobname}{withsolution}{%=
  \usepackage{todonotes}
  \printanswers
}{\usepackage[disable]{todonotes}}

in a myexam.sty file to swi= tch between modes (with or without solutions
and todo notes) and use i= t in the latex file with

\usepackage{myexam}

You coul= d add your own latex class to org-latex-classes and add this
line ther= e.

The jobname has to be passed to latex with something like -jo= bname
withsolution if you want it to be with solutions. I use a Makefi= le for
this purpose which calls latexmk

latexmk -pdf -pdfla= tex=3D"pdflatex --interaction=3Derrorstopmode" -use-make

and add= s -jobname=3D$(basename $@) if asked to create a pdf ending with
withs= olution.pdf. I can send you the Makefile if you're interested.
 
That's very interesting way to solve the problem using LaTeX. Thank you = for sharing this. At the moment I'm leaning more towards solving it using e= macs lisp.
 
To use the jobname from within orgmode, you'll have to change
org-l= atex-pdf-process to use the jobname if needed. I think one way to
achi= eve this is to add a new export backend which is derived from latex
(s= ee org-export-define-derived-backend) and which sets
org-latex-pdf-pro= cess accordingly (and resets it afterwards).
 
Thank you again. I'm thinking of a function like following. I'm using co= mments to express the programming detail that I don't know how to do yet.
 
(deffun org-latex-export-to-pdf-exam ()
  (interactive)
  # do some emacs lisp to add \printanswers to the end of org docum= ent header, i.e., adding a line of #+LATEX_HEADER: \printanswers
  (org-latex-export-to-pdf)
  # do some emacs lips to move the foo.pdf to foo-with_solutions.pd= f
  # do some emacs lisp to add \noprintanswers to the end of org doc= ument header, i.e., removing the line of #+LATEX_HEADER: \printanswers and = adding a line of #+LATEX_HEADER: \noprintanswers
  (org-latex-export-to-pdf)
  # remove the line of #+LATEX_HEADER: \noprintanswers
)
 
I don't know enough emacs lisp to fill in the details here for now. Howe= ver, I think this would be a way to do it within emacs. So each time I call= org-latex-export-to-pdf-exam, it would export two PDF files, one with solu= tions and one without.
 
What do you think?
 
Yours sincerely,
Xianwen
--=_95156a4bee95e9ee70ab85566792cf32--