I often get this kind of error (especially for special links), because the 
regex will use the first part of the first image, and the second part of the 
second image.

Here are some ideas:


1/ Bear in mind if you only need to alter a number, you can use (\d+) instead 
of (.*), so it will only parse numbers instead of unwanted parts of your code 
(with letters).

2/ You can also use a preproc, and alter the source so it would be easier to 
parse later.

For example: here is what I do for resizing images (I also use this to include 
images within a text paragraph:

The syntax is:


[image.jpg][size in mm]{~~~~}



%!preproc: '\[([^ ].*?).png\]\[(\d+)\]\{~~~~\}'  
'WRAPLEFT[\1.png][\2]WRAPLEFT[\2]' 


%!postproc(tex): 'WRAPLEFT([^ 
].*?)WRAPLEFT\[(\d+)\]' \\setlength{\intextsep}{3mm} 
\\FPsub\\result{\2}{15}  \\begin{wrapfigure}{l}{\FPprint\\result mm} 
\1   \\end{wrapfigure}

3/ can't you put all the pictures on different lines, and add a symbol when you 
want the pictures on the same line, or on the opposite to create a linebreak?
Btw, without a blank line in between, txt2tags shouldn't add a linebreak by 
itself, so 


[0.5Images/txt2tagslogo.png]
two images
[0.5Images/txt2tagslogo.png]

should work.

4/ If you don't have more than 4-5 images in the same line, you can create as 
many postproc as there are cases, but it might be complicated to debug later:
%!postproc: 'image1 ... image2 ... image3'    '[width=\1\\textwidth]{image1 ... 
[width=\2\\textwidth]{image2 ... [width=\3\\textwidth]{image3 ...'
%!postproc: 'image1 ... image2'    '[width=\1\\textwidth]{image1 ... 
[width=\2\\textwidth]{image2 ...'
etc.


quite dirty but it might work.






________________________________
 De : Stephen Gibson <[email protected]>
À : [email protected] 
Envoyé le : Vendredi 29 juin 2012 7h00
Objet : [t2t] Image scaling - LaTeX target
 
I am attempting to scale an image by prefixing the file name with the 
appropriate scalefactor.

My images are stored in a directory called 'Images' and so the following 
%!postproc works for a LaTeX target, with a only a single image, but 
fails for multiple images on the same input line:

%!postproc(tex): '\{(.*)Images' '[width=\1\\textwidth]{Images'

No doubt my regular expression syntax/understanding is wrong.

(1) How can I make this work?
(2) Is there a more general regex?    In my case all I need to match is  
{#    of the LaTeX \includegraphics{#filename} where #=scalefactor 
number, and substitute      [width=#\textwidth]{

Thanks,

Steve.

e.g.

txt2tags input file -----------------------------------------------

Title
author
%%date(%c)
%!postproc(tex): '\{(.*)Images' '[width=\1\\textwidth]{Images'

=This works=
The following image scales by 0.5\textwidth in the LaTeX target
[0.5Images/txt2tagslogo.png]


=This fails=
[0.5Images/txt2tagslogo.png] two images [0.5Images/txt2tagslogo.png]


txt2tags tex target output------------------------------------------

\documentclass[a4paper]{article}
\usepackage[margin=15mm]{geometry}
\usepackage{graphicx}
\usepackage{paralist} % needed for compact lists
\usepackage[normalem]{ulem} % needed by strike
\usepackage[urlcolor=blue,colorlinks=true]{hyperref}

\title{Title}
\author{author}
\begin{document}
\date{Fri Jun 29 14:46:50 2012}
\maketitle
\clearpage


\section*{This works}

The following image scales by 0.5$\backslash$textwidth in the LaTeX target
\includegraphics[width=0.5\textwidth]{Images/txt2tagslogo.png}

\section*{This fails}

\includegraphics[width=0.5Images/txt2tagslogo.png} two images 
\includegraphics{0.5\textwidth {Images/txt2tagslogo.png}

% LaTeX2e code generated by txt2tags 2.6.967 (http://txt2tags.org)
% cmdline: txt2tags -t tex ck.t2t
\end{document}





------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
txt2tags-list mailing list
https://lists.sourceforge.net/lists/listinfo/txt2tags-list

Reply via email to