emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* New LaTeX exporter, link to \ref
@ 2012-09-16  1:02 Thomas S. Dye
  2012-09-16  7:40 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas S. Dye @ 2012-09-16  1:02 UTC (permalink / raw)
  To: Org-mode

Aloha Nicolas,

This in the org file:

(fig. [[fig:old-wood]])

exports to this in the latex file:

(fig. \ref{fig-old-wood})

I think the exporter is replacing the colon with a hyphen, which breaks
the reference.

Also, is there some way to toggle a non-breaking space, e.g.,
(fig.~\ref{fig:old-wood})?  I thought to use \tilde{}, but this wouldn't
work with other back ends.

All the best,
Tom
-- 
T.S. Dye & Colleagues, Archaeologists
735 Bishop St, Suite 315, Honolulu, HI 96813
Tel: 808-529-0866, Fax: 808-529-0884
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New LaTeX exporter, link to \ref
  2012-09-16  1:02 New LaTeX exporter, link to \ref Thomas S. Dye
@ 2012-09-16  7:40 ` Nicolas Goaziou
  2012-09-16 18:05   ` Thomas S. Dye
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2012-09-16  7:40 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Org-mode

Hello,

tsd@tsdye.com (Thomas S. Dye) writes:

> This in the org file:
>
> (fig. [[fig:old-wood]])
>
> exports to this in the latex file:
>
> (fig. \ref{fig-old-wood})
>
> I think the exporter is replacing the colon with a hyphen, which breaks
> the reference.

Correct. It's done by the function `org-export-solidify-link-text'. The
problem is that it isn't used consistently across the back-end. It
should be fixed now.

> Also, is there some way to toggle a non-breaking space, e.g.,
> (fig.~\ref{fig:old-wood})?  I thought to use \tilde{}, but this wouldn't
> work with other back ends.

You may use \nbsp{} entity.

My keyboard layout allows for easy access to non-breaking spaces. So
I use the following instead (_ character stands for the non-breaking
space):

#+begin_src emacs-lisp
(defun ngz-latex-filter-nobreaks (text backend info)
  "Ensure \"_\" are properly handled in Beamer/LaTeX export."
  (when (memq backend '(e-beamer e-latex))
    (replace-regexp-in-string "_" "~" text)))
(add-to-list 'org-export-filter-plain-text-functions
             'ngz-latex-filter-nobreaks)
#+end_src

HTH,


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New LaTeX exporter, link to \ref
  2012-09-16  7:40 ` Nicolas Goaziou
@ 2012-09-16 18:05   ` Thomas S. Dye
  2012-09-16 20:42     ` Sebastien Vauban
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas S. Dye @ 2012-09-16 18:05 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org-mode

Aloha Nicolas,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Hello,
>
> tsd@tsdye.com (Thomas S. Dye) writes:
>
>> This in the org file:
>>
>> (fig. [[fig:old-wood]])
>>
>> exports to this in the latex file:
>>
>> (fig. \ref{fig-old-wood})
>>
>> I think the exporter is replacing the colon with a hyphen, which breaks
>> the reference.
>
> Correct. It's done by the function `org-export-solidify-link-text'. The
> problem is that it isn't used consistently across the back-end. It
> should be fixed now.

Yes, link text is consistently changed so cross references work.  Thanks.

>> Also, is there some way to toggle a non-breaking space, e.g.,
>> (fig.~\ref{fig:old-wood})?  I thought to use \tilde{}, but this wouldn't
>> work with other back ends.
>
> You may use \nbsp{} entity.
>
> My keyboard layout allows for easy access to non-breaking spaces. So
> I use the following instead (_ character stands for the non-breaking
> space):
>
> #+begin_src emacs-lisp
> (defun ngz-latex-filter-nobreaks (text backend info)
>   "Ensure \"_\" are properly handled in Beamer/LaTeX export."
>   (when (memq backend '(e-beamer e-latex))
>     (replace-regexp-in-string "_" "~" text)))
> (add-to-list 'org-export-filter-plain-text-functions
>              'ngz-latex-filter-nobreaks)
> #+end_src

Thanks very much for the filter, which makes for an aesthetically
pleasing org buffer.  I changed the underscore to a non-breaking
space character in the call to replace-regexp-in-string and now get
tildes in my LaTeX export.

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New LaTeX exporter, link to \ref
  2012-09-16 18:05   ` Thomas S. Dye
@ 2012-09-16 20:42     ` Sebastien Vauban
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastien Vauban @ 2012-09-16 20:42 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Thomas,

Thomas S. Dye wrote:
>> I use the following instead (_ character stands for the non-breaking
>> space):
>>
>> #+begin_src emacs-lisp
>> (defun ngz-latex-filter-nobreaks (text backend info)
>>   "Ensure \"_\" are properly handled in Beamer/LaTeX export."
>>   (when (memq backend '(e-beamer e-latex))
>>     (replace-regexp-in-string "_" "~" text)))
>> (add-to-list 'org-export-filter-plain-text-functions
>>              'ngz-latex-filter-nobreaks)
>> #+end_src
>
> Thanks very much for the filter, which makes for an aesthetically
> pleasing org buffer.  I changed the underscore to a non-breaking
> space character in the call to replace-regexp-in-string and now get
> tildes in my LaTeX export.

I use this:

#+begin_src emacs-lisp
  ;; replace space by nobreak-space where it fits well
  (defun my/replace-space-before-colon ()
    "Replace space by nobreak-space in front of a colon."
    (interactive)
    (cond ((eq (char-before) ?\ ) ;; normal space
           (backward-delete-char 1)
           (cond ((equal mode-name "PDFLaTeX")
                  (insert "~:"))
                 ((equal mode-name "Org")
                  (if (and (fboundp 'org-in-src-block-p)
                           (org-in-src-block-p))
                      (insert " :")
                    (insert " :")))
                 ;; FIXME Don't put a nobreak space when specifying Org
                 ;; Babel properties (such as :exports both)
                 (t
                  (insert " :")))) ;; non-breaking space
          ;; remove nobreak-space if two colons are put one after the
          ;; other (for terms and definitions in Org)
          ((and (eq (char-before) ?\:)
                (eq (char-before (- (point) 1)) ?\ ))
           (backward-delete-char 2)
           (insert " ::")) ;; normal space

          (t
           (insert ":"))
          ))

  ;; French typography
  (defun my/nobreak-keys ()
    "If any, replace space in front of colons, question marks, exclamation
  marks, etc. to avoid line break problems."
    (interactive)
    (local-set-key ":" 'my/replace-space-before-colon))

  (add-hook 'text-mode-hook 'my/nobreak-keys)
  (add-hook 'message-mode-hook 'my/nobreak-keys)
#+end_src

in order to have real nbsp as well in my Org buffer. They aren't translated
neither to HTML nor to LaTeX (they're simply copied across), allowing for
consistent view in all the buffers (source + outputs).

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-16 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-16  1:02 New LaTeX exporter, link to \ref Thomas S. Dye
2012-09-16  7:40 ` Nicolas Goaziou
2012-09-16 18:05   ` Thomas S. Dye
2012-09-16 20:42     ` Sebastien Vauban

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).