Search Postgresql Archives

Re: psql latex and newlines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On vr, 2012-02-10 at 19:25 -0500, Bruce Momjian wrote:
> On Mon, Dec 12, 2011 at 07:15:12PM +0100, Wim Bertels wrote:
> > Hallo,
> > 
> > psql latex output format needs to differentiate between a newline and a
> > tabularnewline.
> > 
> > the problem arises when u have a field value that contains a newline
> > character, when this field is not the first column, then all the data
> > after this newline comes in the first column..
> > 
> > u can try this out, writing a function or table,
> > and then add 'enters' or newline in the COMMENT on this function or
> > table.
> > 
> > the \pset recordsep doesn't solve this, since the mistakes take place
> > within the same record.
> 
> Can you give me a self-contained test case I can use so I can use it to
> fix the to code?

Hi Bruce,

i have attached some files:
1 sql file 
1 corresponding output file
1 full latex file using the output of the above file

i don't see and easy search/replace fix for this problem,
maybe using the \multirow and \multicolumn options in latex is the most
general solution,
as all the others seems to need concrete dimensions (as width)

http://www.google.com/search?client=ubuntu&channel=fs&q=newline+tabular
+cell+latex&ie=utf-8&oe=utf-8

http://andrewjpage.com/index.php?/archives/43-Multirow-and-multicolumn-spanning-with-latex-tables.html

There is also a problem with long lines as u can test by uncommenting
the t4bruce3 function.

info about the versions:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 10.04.3 LTS
Release:	10.04
Codename:	lucid
wim@zwerfkat:~/wet/gb/postgresql/debug$ psql -V
psql (PostgreSQL) 8.4.10
contains support for command-line editing

mvg,
Wim Bertels


> 

\documentclass[12pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\author{Wim Bertels}
\begin{document}

\begin{tabular}{l | l | l}
\textit{Schema} & \textit{Name} & \textit{Description} \\
\hline
latex\_test & t4bruce1 & This function and so on enter\\		another enter,\\		just one more.\\         \\
latex\_test & t4bruce2 & This function and so on enter\\		another enter,\\		just one more,\\		so now have even one more.\\         \\
\end{tabular}

\noindent

% with a \\ replaced by a newline, doenst help
\begin{tabular}{l | l | l}
\textit{Schema} & \textit{Name} & \textit{Description} \\
\hline
latex\_test & t4bruce1 & This function and so on enter\newline		another enter,\\		just one more.\\         \\
latex\_test & t4bruce2 & This function and so on enter\\		another enter,\\		just one more,\\		so now have even one more.\\         \\
\end{tabular}

\noindent

%\begin{tabular}{l | l | l}
%\textit{Schema} & \textit{Name} & \textit{Description} \\
%\hline
%latex\_test & t4bruce1 & This function and so on enter\\		another enter,\\		just one more.\\         \\
%latex\_test & t4bruce2 & This function and so on enter\\		another enter,\\		just one more,\\		so now have even one more.\\         \\
%latex\_test & t4bruce3 & This function and so on enter\\		another enter,\\		just one more,this is a very long line without an enter, just one more,this is a very long line without an enter\\		so now have even one more.\\         \\
%\end{tabular}
%
%\noindent

\end{document}
DROP SCHEMA
CREATE SCHEMA
SET
CREATE FUNCTION
COMMENT
CREATE FUNCTION
COMMENT
\begin{tabular}{l | l | l}
\textit{Schema} & \textit{Name} & \textit{Description} \\
\hline
latex\_test & t4bruce1 & This function and so on enter\\		another enter,\\		just one more.\\         \\
latex\_test & t4bruce2 & This function and so on enter\\		another enter,\\		just one more,\\		so now have even one more.\\         \\
\end{tabular}

\noindent (2 rows) \\

\pset format latex
\o out.tex


DROP SCHEMA IF EXISTS latex_test CASCADE;
CREATE SCHEMA latex_test;

SET SEARCH_PATH TO latex_test;


CREATE OR REPLACE FUNCTION t4bruce1(i integer)
        RETURNS void AS $_$
DECLARE
BEGIN
END;
$_$
 LANGUAGE 'plpgsql'
 VOLATILE;

COMMENT ON FUNCTION t4bruce1(i integer)
    IS  $_$This function and so on enter
		another enter,
		just one more.
        $_$;

        
CREATE OR REPLACE FUNCTION t4bruce2(v varchar)
        RETURNS varchar AS $_$
DECLARE
BEGIN
	RETURN	v;
END;
$_$
 LANGUAGE 'plpgsql'
 VOLATILE;

COMMENT ON FUNCTION t4bruce2(v varchar)
    IS  $_$This function and so on enter
		another enter,
		just one more,
		so now have even one more.
        $_$;
        
/*
CREATE OR REPLACE FUNCTION t4bruce3(v varchar)
        RETURNS varchar AS $_$
DECLARE
BEGIN
	RETURN	v;
END;
$_$
 LANGUAGE 'plpgsql'
 VOLATILE;

COMMENT ON FUNCTION t4bruce3(v varchar)
    IS  $_$This function and so on enter
		another enter,
		just one more,this is a very long line without an enter, just one more,this is a very long line without an enter
		so now have even one more.
        $_$;
*/


SELECT n.nspname as "Schema",
  p.proname as "Name",
  pg_catalog.obj_description(p.oid, 'pg_proc') as "Description"
FROM pg_catalog.pg_proc p
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
     LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang
WHERE pg_catalog.pg_function_is_visible(p.oid)
      AND n.nspname = 'latex_test'
ORDER BY 1, 2;

\o
\pset format aligned
-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux